我有两个表tbl_expense
和tbl_miscellaneous_category
。在tbl_expense
我有一些领域。主要是id
和category
。在tbl_miscellaneous_category id and name
.这个名字只不过是tbl_expense table
category
.我需要这样的 o/p:ID 名称
SELECT te.id,te.category
FROM tbl_expense te
inner join tbl_miscellaneous_category tmc
on te.category=tmc.id
WHERE te.id= '1'
目前还不太清楚您要查找的内容,但我相信以下内容会起作用:
SELECT
te.id, tmc.name
FROM
tbl_expense te inner join tbl_miscellaneous_category tmc
on te.category=tmc.id WHERE te.id= '1'
此解决方案将提供 tbl_miscellaneous_category
中name
列提供的类别名称。
代替te
,使用包含category
名称的tmc
SELECT te.id,
tmc.name
FROM tbl_expense te
INNER JOIN tbl_miscellaneous_category tmc
ON te.category = tmc.id
WHERE te.id = '1'