mysql search over two or more table?
sorry i am a very mysql beginner:
I want to search over two (or three) tables
Table: persons
id | name | age
1 | AA | 20
2 | BB | 30
3 | CC | 40
Table: data
id | person_id | item
1 | 2 | nail
2 | 2 | hammer
3 | 1 | hammer
4 | 2 | hat
person.id is data.person_id
So i have the following questions: - How can i find all people who has a
hammer? - How can i find all people who have no item? - How can i find all
people who 20 and have hammer? (just add to where 'AND p.age = 20' i think
now) - How can i find all persons who has a item?
I know i can search over more tables with JOIN but i don't get it to work
now.
Thanks in advance!
No comments:
Post a Comment