Reputation: 330
I've got the following table structure but when I try the below select statement I get back an empty result with no data. I'm trying to get the data from table A where it links up with table B and the section is new. So in this example I should get rows; two and three.
What am I doing wrong ? :s
Thanks in advance
table A
id name primarygroup
1 one 1
2 two 2
3 three 2
table B
id section
1 old
2 new
3 young
SELECT * FROM A
INNER JOIN B ON A.primarygroup = B.id
WHERE B.section = "new"
Upvotes: 1
Views: 116
Reputation: 6534
Check this SQL Fiddle. Your query is correct, just need to change the double quotes by single quotes. So instead of "new" try 'new'
And by the way, edit your tags and add wich RDBMS are you using. My sample code is for SQL Server.
Upvotes: 5
Reputation: 18749
try single quotes
" -> '
SELECT * FROM A
INNER JOIN B ON A.primarygroup = B.id
WHERE B.section = 'new'
Also, Edit your query to select the fields you want, or you are getting id
twice there.
Upvotes: 2