0

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
2
  • SELECT * FROM items WHERE name = "A" AND status = 1 ? ah 2 tables nvm Commented Jul 17, 2016 at 21:24
  • Thanks but status column is not in items table. It is in sigle table with same key. Commented Jul 17, 2016 at 21:25

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

2 Comments

thank you very much and sorry for stupid question but this is my first time when i have to use inner join so now I will know next time :)
Do not apologize .. I do not think there are stupid questions in this area .. just some things already have the answers others are still trying and SO is a step in this very popular search .. anyway if my answer is right .. please mark it as accepted .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.