Reputation: 2186
I have two tables in MySQL:
Table1:
cname
a
b
f
Table2:
character | account
a | 1
b | 2
c | 3
d | 4
e | 5
f | 6
g | 7
I want to select all accounts from two tables which cname = character
I've tried this:
SELECT account FROM table1,table2 WHERE cname = character
But it returns empty. I'm sure I'm missing something simple...
Any help would be appreciated.
Upvotes: 1
Views: 1918
Reputation: 1026
Probably your data may have whitespace or any other special character appended or prepended to it. Make sure your data is fine. Better try using trim.
Upvotes: 0
Reputation: 27354
You need to specify your table name into query.
SELECT account FROM table1,table2 WHERE table1.cname = table2.character
OR
Use JOINS
SELECT table2.account FROM table1
LEFT JOIN table2 ON table1.cname = table2.character
Upvotes: 3