Reputation: 24061
This is my inner join, it doesnt appear to work, is there anything wrong with the syntax?
$db->query("SELECT name FROM stockists INNER JOIN shops ON stockists.name = shops.name");
Upvotes: 0
Views: 171
Reputation: 7097
Try this query
SELECT s.`name` FROM stockists st INNER JOIN shops s ON st.`name`= s.`name`
Execute....
Upvotes: 2
Reputation: 125456
change to
SELECT shops.name
the column name
is ambiguous, exist in both tables (shops and stockists)
like "SELECT shops.name FROM stockists INNER JOIN shops ON stockists.name = shops.name"
read on stackoverflow
Upvotes: 1
Reputation: 2185
You wrote:
$db->query("SELECT name FROM stockists INNER JOIN shops ON stockists.name = shops.name");
The problem here is that you should specify which name you would like to have :
$db->query("SELECT stockists.name FROM stockists INNER JOIN shops ON stockists.name = shops.name");
or
$db->query("SELECT shops.name FROM stockists INNER JOIN shops ON stockists.name = shops.name");
Upvotes: 1