RabbieBurns Posted July 13, 2016 Posted July 13, 2016 I imagine this should be fairly straight forward but I cant seem to find any examples of it to help me. I have the following Postgre SQL query: select field1, field2, field3, field4 from table where field1 = 'text' and field4 is not null Which works well, and displays the results in the format Field1 | Field2 | Field3 | Field4 I am trying to concatenate Field2 and Field3 results so it will show the results as: Field1 | Field2Field3 | Field4 What would the SQL query for this be please? Many thanks RB
howartp Posted July 13, 2016 Posted July 13, 2016 Try: Select field1, concat(field2, field3), field4 ....... 1
Spl1t Posted July 13, 2016 Posted July 13, 2016 (edited) Or you could try SELECT Field1, Field2 + ' ' + Field3 AS [New Field Name for both columns], Field4 FROM table Essentially I am just joining the two fields together and separating them with an empty string with a space. If you don't want the space then it will just be Field2+Field3 as [New Field name] Edited July 13, 2016 by Spl1t 1
jdoyle Posted July 13, 2016 Posted July 13, 2016 an example from the w3schools site combining the CONCAT and Alias options used in the above : SELECT CustomerName, CONCAT(Address,', ',City,', ',PostalCode,', ',Country) AS Address FROM Customers; can be found at SQL Aliases 1
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