Reputation: 21371
SELECT u.user_id, u.first_name, u.last_name, i.path AS image_path
FROM bgy_users u
LEFT JOIN bgy_images i ON i.image_id = u.image_id
WHERE u.commentary_id = '0'
Unknown column 'u.image_id' in 'on clause'
When there definitely is a column image_id
in table bgy_users
What am I doing wrong?
Result for DESCRIBE BGY_USERS
Result for DESCRIBE BGY_IMAGES
Upvotes: 2
Views: 173
Reputation: 416
This is real weird and the only thing I can think of is that you are querying the wrong database. Confirm in your application code that you are using correct connection string to connect to the database.
You can also issue 'select database()' from your application to find out the name of the current database you are connected to.
Upvotes: 0
Reputation: 27478
Can you do a
select image_id from bgy_users;
I am asking because the only time I have seen anything like this it has either been a code page problem or there have been non printable characters creeping into your query.
Upvotes: 0
Reputation: 29294
try this
SELECT u.user_id, u.first_name, u.last_name, i.path AS image_path
FROM (bgy_users u)
LEFT JOIN (bgy_images i) ON i.image_id = u.image_id
WHERE u.commentary_id = '0'
the only difference is the parenthesis around table names
Upvotes: 0
Reputation: 319
The query is perfectly alright mySQL 5.0.18-nt-log. Such error will be prompted only when the field does not exist, in case double check your column name image_id in bgy_users table.
Upvotes: 1