Hi I am having trouble getting nested results in my output table.
SELECT *, users.Name FROM person WHERE person.User IN
(
SELECT Id FROM users WHERE users.Id = "0014082f-5e17-4eaa-aebc-a22800c59ccc"
)
In this example i want to select next to the data from person the Username of the nested table users. this piece of code gives the following error
#1054 - Unknown column 'users.Name' in 'field list'
but what can i do to fix it?
EDIT:
i tried to simplify things but it only made my question more vague This is the original code with the JOIN tip from the awnsers
SELECT * FROM behandelaars LEFT JOIN
(
SELECT Id, Name FROM users WHERE users.Id
IN(
SELECT User FROM usersinrole WHERE Role IN (
SELECT Id FROM roles WHERE Name = "BeloningHintingSysteem"
)
)
AND users.Id NOT IN(
SELECT User FROM usersinrole WHERE Role IN (
SELECT Id FROM roles WHERE Name = "UitgelslotenVanOnderzoek"
)
)
)
ON behandelaars.User = users.Id
thx Matthy
IN(/* subquery */). It takes a bit of adjustment in the way you think but in the long run it's very useful.Namecolumn doesn't exist inuserstableuserstable name is not visible in the main query.