I want to create new tables in the query and use them at the end for a final query. I don't remember what the syntax is and can't find it anywhere. (here is a basic example for illustration only).
phones as
(
SELECT phone_number from customers
)
emails as
(
SELECT emails from customers
)
// do something with both
You are looking for CTE's
With phones as
(
SELECT phone_number from customers
)
,emails as
(
SELECT emails from customers
)
select * from phones--/emails
You are looking for a Common Table Expression (CTE). These are introduced using with:
with phones as (
SELECT phone_number from customers
),
emails as (
SELECT emails from customers
)
select . . .;
Your example selects don't seem particularly useful, but I assume they are just for illustration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With