Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Is this a subquery I need?
people table fields:
id,first_name,last_name,login,manager_id
I need to get all the info, plus the login of the manager where manager_id references the record in the people table.
This is why I'm not a DBA
@bitzbyte

This comment has been minimized.

Copy link

@bitzbyte bitzbyte commented Feb 4, 2014

I'd use a JOIN:

SELECT L.first_name, L.last_name, L.login, R.login
    FROM Table AS L
    LEFT OUTER JOIN Table AS R ON (L.manager_id = R.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment