SELECTĬoncat_ws (', ', stud_fname, stud_lname) AS student_full_name We will concatenate the stud_fname and stud_lname of the student table by using the following statement, which a single comma and space will separate. The PostgreSQL also provides the function named CONCAT_WS, which means concatenate with separator. We can use the PostgreSQL CONCAT() function for various operations like we need to build a statement that will give us the resultant string by combining the following strings:ĬONCAT('Student name is of ', LENGTH (stud_fname), ' characters' ) SELECTĬONCAT (stud_fname, ' ', stud_lname) AS "Students fullname" Using the following SQL statement and snapshot, we will concatenate the values of the stud_fname and stud_lname columns of the student table. Illustrate the above INSERT statement’s result using the following SQL statement and snapshot. INSERT INTO student(stud_fname,stud_lname) We will insert some data into the student table using the following INSERT INTO statement. We will create a table named ‘student’ by using the CREATE TABLE statement as follows: create table student SELECT CONCAT ('Edu', 'CBA') as CONCAT_TABLE Illustrate the CONCAT function by using the following SELECT statement and a snapshot. The string type means the input argument should be of any of the following data types:Ĭonsider the following example, which concatenates the two strings by using the PostgreSQL CONCAT() function.The input argument provided to the function should be string type or convertible to the string type.The PostgreSQL CONCAT() considers each list element as an argument, as this function is a VARIADIC function that can take any number of elements as input.How does PostgreSQL CONCAT() Function Work? )Įxplanation: The PostgreSQL CONCAT() function inputs an argument list. Consider the following syntax of the CONCAT() function: CONCAT(string_1, string_2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |