Category:3D graphics software
Category:Computer-aided design software for Windows
Category:Computer-aided design software for LinuxQ:
Using where conditions with join query using a subquery
I am trying to create a report that lists out a group of users who have a particular value in one of their accounts, the report will use a join query and a subquery, I have the two queries working on their own, however when I try to use them together they no longer work. Here is my query:
SELECT u.id,
u.username,
u.email,
n.username,
n.email,
ISNULL(at.id,0) AS accountTypeId,
ISNULL(at.accountType,0) AS accountTypeName
FROM users u
LEFT JOIN accounts at ON (at.user = u.id)
LEFT JOIN accounts n ON (n.user = u.id)
LEFT JOIN nb_users_accounts nua ON (nua.user = u.id)
WHERE (n.username = 'Fred')
AND (u.accountType = 1)
AND (at.accountType = 1)
AND (at.accountType = 1)
I have used a number of variations on this with the same result:
Invalid column name 'at.accountType'
Is there a way to combine these queries?
A:
What I ended up using ac619d1d87
Related links: