I need to fetch all entries from a table titled users and JOIN a user from the same table based on a userID in the original users entry . I have a simple JOIN query that completes this requirement but I only want to return two columns (userID and fullName) during the JOIN. Currently I'm returning the whole user entry from the JOIN and obviously the column names overlap. For our application's purposes, I need to rename the columns returned from the JOIN. I'm currently using the query below.
SELECT * FROM users u1
JOIN users AS u2
ON(u1.dealer = u2.userID)
This seems like it should be relatively simple but I can't seem to figure it out. I've searched for hours but haven't found a clear solution.
SELECT u1.*, u2.userID as dealer_id, u2.fullName as dealer_name?