PREPEND¶
The PREPEND function in SQL is used to prepend an element to a list.
Syntax¶
list: The list to which you want to prepend the element.element: The element that you want to prepend to the list.
Examples¶
First, create a table named Prepend with columns for the list, an integer element, and a text element:
Insert some data into the Prepend table:
Use the PREPEND function to prepend the integer element to the list:
Use the PREPEND function to prepend the text element to the list:
The PREPEND function requires a list as the first parameter. If you try to use it with a non-list value, an error will occur:
You can also use the PREPEND function when inserting data into a table. First, create a table named Foo with a column for the list:
Then, insert data into the Foo table using the PREPEND function:
Finally, retrieve the list from the Foo table: