I don’t get why when I SELECT pizzeria_name and person_name in FROM nested query it doesn’t work but when I put (*)
instead i see two columns displayed on the screen with names person_name and pizzeria_name. How can i substitute (*)
to see the same result?
SELECT ( SELECT person.name FROM person WHERE person.id = pv.person_id ) AS person_name,
( SELECT pizzeria.name FROM pizzeria WHERE pizzeria.id = pv.pizzeria_id ) AS pizzeria_name
FROM (
SELECT *
FROM person_visits
WHERE visit_date BETWEEN '2022-01-07' AND '2022-01-09'
) AS pv
ORDER BY person_name ASC, pizzeria_name DESC;
I tried everything pizzeria.id, pv.pizzeria_id etc but it doesn’t work
Any types of Joins are prohibited
That’s how my table is looks like
[1]: https://i.stack.imgur.com/vaWVB.png
2
Answers
Delete the subqueries and use a plain query:
Standard naming convention of columns has been assumed.
If you absolutely must use subqueries: