1

I'm using Postgres, I've this table:

id | fieldname | value
----------------------
1  | price     | 10000

and

id | dyn_field | dyn_value
--------------------------
1  | bathroom  | 2
2  | bedroom   | 4

and I would like to get the following output

field     | value
---------------------
price     | 10000
bathroom  | 2
bedroom   | 4

What query can be used for get these output,.? thanks,.

3 Answers 3

3
SELECT fieldname AS field, value AS value
FROM tableOne
UNION ALL
SELECT dyn_field AS field, dyn_value AS value
FROM tableTwo
Sign up to request clarification or add additional context in comments.

Comments

1
 SELECT fieldname, value FROM this_table
 UNION ALL 
 SELECT dyn_field, dyn_value FROM and_table

(You didn't specify the table names, so I made them up).

Comments

1

Try this:

SELECT fieldname as field, value 
FROM table1 
UNION select dyn_field as field, dyn_value as value 
FROM table2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.