我有兩個表tbl_expense
和tbl_miscellaneous_category
。在tbl_expense
我有一些領域。主要是id
和category
。在tbl_miscellaneous_category id and name
。這個名字只不過是category
的tbl_expense table
。我需要的O/P是這樣的:ID名稱內部加入mysql錯誤
SELECT te.id,te.category
FROM tbl_expense te
inner join tbl_miscellaneous_category tmc
on te.category=tmc.id
WHERE te.id= '1'
什麼是錯誤的名字嗎? – 2012-08-08 06:39:44
SELECT te.id,tmc.name FROM tbl_expense TE內加入tbl_miscellaneous_category TMC 上te.category = tmc.id WHERE te.id = '1' – sachin 2012-08-08 06:40:54
僅選擇te.id,te.category,這是兩個ID的。只需將類別名稱添加到SELECT。 – Kao 2012-08-08 06:43:16