Tuesday 13 January 2015

Join Values in Table Columns and Add Spaces

In the following example, you added a couple of constant values to your SELECT statement for better readability. First, you added a space between the two names with the help of a space character – represented by two single quotes having a single space between them. Secondly, you added a comma (also enclosed in single quotes) to separate the name of an employee from his/her job id.


    SQL Statement :

SELECT       first_name || ‘ ‘ || last_name || ‘, ’ ||job_id  “Employees”
FROM          employees;

    Output :






















NOTE
·         Access and SQL Server use + for concatenation.
·         Oracle, DB2, SQLite, and PostgreSQL support ||.
·         MySQL and MariaDB provide Concat() function for this purpose.


No comments:

Post a Comment