Reputation: 23
WITH temp(k) AS (VALUES (15252332445), (15253665080), (15241848778),
(11813086136), (15253665080) ) LEFT join hello.transaction_job B on
B.id=temp.k SELECT * FROM temp,B.id,B.msisdn
Trying to join a common table expression with standard table, but failed
Can you guys tell me why?
Upvotes: 2
Views: 406
Reputation: 2014
You can also write using union
within cte
WITH TEMP (k)
AS (
SELECT 15252332445
UNION ALL
SELECT 15253665080
UNION ALL
SELECT 15241848778
UNION ALL
SELECT 11813086136
UNION ALL
SELECT 15253665080
)
SELECT B.id, B.msisdn
FROM TEMP t
LEFT JOIN hello.transaction_job B ON B.id = t.k
Upvotes: 0
Reputation:
The SELECT
needs to be before the JOIN as with every join
WITH temp(k) AS (
VALUES (15252332445), (15253665080), (15241848778),
(11813086136), (15253665080)
)
SELECT B.id, B.msisdn
FROM temp t
LEFT join hello.transaction_job B on B.id = t.k;
Upvotes: 4
Reputation: 51529
maybe you wanted smth like:
WITH temp(k) AS (VALUES (15252332445), (15253665080), (15241848778),
(11813086136), (15253665080) )
, b as (select * from temp LEFT join hello.transaction_job B on
B.id=temp.k)
SELECT * FROM temp,B.id,B.msisdn
Upvotes: 0