Guest sparrez Posted January 18, 2007 Share Posted January 18, 2007 HelloI'm trying to join to tables that have the same columns eg.SELECT COL1, COL2, COL3 FROM TBL1UNION ALLSELECT COL1, COL2, COL3 FROM TBL2That works fine, but I would like COL3 from TBL2 to have another name eg. COL4so my result becomesCOL1 | COL2 | COL3 | COL4val |val |NULL |val |val |val |val |NULL |val |val |NULL |val |val |val |val |NULL |and the respective empty rows in COL3 just become NULLHow do I achieve this? tired AS COL4 but that didn't work Link to comment Share on other sites More sharing options...
xpriens Posted January 22, 2007 Share Posted January 22, 2007 This can be achieved by the following,SELECT COL1, COL2, COL3 as COL4 FROM TBL1UNION ALLSELECT COL1, COL2, COL3 as COL4 FROM TBL2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now