mardi 26 mai 2015

Is there any way to simplify these two subqueries into one?

I have the call

SELECT *,
    (SELECT first_name||' '||last_name FROM users WHERE user_id=U.invited_by) AS inviter,
    (SELECT first_name FROM users WHERE user_id=U.invited_by) AS inviter_first
    FROM users AS U

and that works. But as you can see, the two subqueries are both retrieving pretty data from the same row. Is there any way to simplify the two SELECT calls as one and still get the same results?

Aucun commentaire:

Enregistrer un commentaire