SELECT a.catid
, b.catname
, a.details
, a.debit
, a.credit
, a.balance
FROM manual_update a
WHERE catid IN(SELECT catid FROM category) b
WHERE a.catid = b.catid
AND a.month = 'July'
AND a.year ='2005'
OR a.balance = ''
答案 0 :(得分:1)
查询有多个
where
关键字。
正确的查询应该是这样的:
SELECT a.catid,b.catname,a.details,a.debit,a.credit,a.balance
FROM manual_update a
WHERE a.catid IN(SELECT catid FROM category) b AND a.catid=b.catid AND
a.month='July' AND a.year ='2005' OR a.balance = ''
答案 1 :(得分:0)
我认为您想要在类别和manual_update之间进行连接。
SELECT a.catid
, b.catname
, a.details
, a.debit
, a.credit
FROM manual_update a
INNER JOIN category b
ON b.catid = a.catid
WHERE a.month = 'July'
AND a.year ='2005'
OR a.balance = ''
您可以尝试使用此sqlfiddle(没有数据但您可以根据需要添加它们):