coala
coala

Reputation: 235

Create temporary table with fixed values

How do I create a temporary table in PostgreSQL that has one column "AC" and consists of these 4-digit values:

In essence the table has more values, this should just serve as an example.

Upvotes: 2

Views: 15923

Answers (1)

AjV Jsy
AjV Jsy

Reputation: 6095

If you only need the temp table for one SQL query, then you can hard-code the data into a Common Table Expression as follows :

WITH temp_table AS
(
  SELECT 'Zoom' AS AC UNION
  SELECT 'Inci' UNION
  SELECT 'Fend'
)
SELECT * FROM temp_table

see it work at http://sqlfiddle.com/#!15/f88ac/2
(that CTE syntax also works with MS SQL)
HTH

Upvotes: 13

Related Questions