内部联接在 mysql 错误


Inner join in mysql error

我有两个表tbl_expensetbl_miscellaneous_category。在tbl_expense我有一些领域。主要是idcategory。在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_categoryname列提供的类别名称。

代替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'