JackDavis JackDavis - 6 months ago 12
SQL Question

MySQL query in two tables

Is possible to get all items with name = "A" AND status = 1? Name is in table items and status is in table status.

Something like

SELECT * FROM items WHERE name = "A" AND id AS status.itemid = 1
but this does not work.

Db structure:

TABLE items:

id name
1 A
2 A
3 B

TABLE status:

itemid status
1 1
2 1
3 2


use inner join

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;