Reputation: 1515
I'm used to do MySQL querys only with one table. Now I need to connect two and have no idea :/
Table: cat_member
member | cat
11 | 3
14 | 4
12 | 3
Table: members
id | company
11 | Foo
14 | Bar
....
I want to select from cat_member where cat=3 for example and display the company names from the table members
This is how far I've come:
SELECT cat_medlem.member,
members.company
FROM members
WHERE cat_medlem.cat = 3
INNER JOIN members
ON cat_member.member=members.id
Any ideas? Thanks!
Upvotes: 1
Views: 77
Reputation: 44844
The where condition should go after the join, also you probably looking to join members
with cat_member
SELECT cat_member.member,
members.company
FROM members
INNER JOIN cat_member
ON cat_member.member=members.id
WHERE cat_member.cat = 3
Upvotes: 1