可以获得名称=" A" AND status = 1?名称在表项中,状态为表状态。
像SELECT * FROM items WHERE name = "A" AND id AS status.itemid = 1
这样的东西,但这不起作用。
Db结构:
表项目:
id name
1 A
2 A
3 B
TABLE状态:
itemid status
1 1
2 1
3 2
答案 0 :(得分:1)
使用内部联接
select a.name, b.status
from items as a
inner join status as b on a.id = b.itemid
where a.name ='A' and b.status =1;