I am using postgresql and have a table 'sometable' which looks like this
id | ref_id | a_remarks | a_date | b_remarks | b_date
1 | 32 | 'send xyz' | 20/06/2014 | 'file send' | 22/06/2014
2 | 32 | 'send abc' | 25/06/2014 | 'file send' | 01/07/2014
but while displaying it to user i need to display it this way
20/06/2014 Send xyz
22/06/2014 file send
25/06/2014 send abc
01/07/2014 file send
so i am unable to view data one after the other since it is in different columns. Can any one help me with this?? Thanks In Advance.
Create one query that selects a_remarks and a_date, union it with another query that selects b_remarks and b_date and then order by id. If it's important to strip out the id then create the unions in a subquery and just drop the id in the outer query. Like this...
SELECT t.date, t.remarks FROM (SELECT id, a_date AS date, a_remarks AS remarks FROM sometable UNION SELECT id, b_date AS date, b_remarks AS remarks ORDER BY id) t;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments