Reputation: 1293
I'm getting some problems making a simple SELECT
w/ LEFT JOIN
query:
SELECT
a.sttgs_id, a.sttgs_description,
(c.uss_id IS NOT NULL) as has
FROM
(mt_user b, mt_settings a
LEFT JOIN mt_user_settings c
ON c.sttgs_id=a.sttgs_id AND
b.usr_id=c.usr_id
)
WHERE c.usr_id=2
PHPMyAdmin says: #1054 - Unknown column 'b.usr_id' in 'on clause'
.
I really don't know other way to do the SELECT
.
Greetings.
Edit: show create table mt_user
Upvotes: 0
Views: 55
Reputation: 37233
Try this
SELECT
a.sttgs_id,
a.sttgs_description,
c.uss_id as has
FROM mt_user b
LEFT JOIN mt_user_settings c on b.usr_id=c.usr_id
LEFT JOIN mt_settings a ON c.sttgs_id=a.sttgs_id --you may need INNER JOIN here
WHERE c.usr_id=2
AND c.uss_id IS NOT NULL
Upvotes: 1