In Oracle, the || operator can be used to splice fields, and a single quotation mark '' can be used when inserting spaces between fields. For example, concatenate the FirstName and LastName fields and add spaces: SELECT FirstName || ' ' || LastName AS FullName FROM myTable;
How in Oracle Concatenate fields and add spaces
In Oracle, you can concatenate strings using the ||
operator. To add spaces, just use a single quote (') between the strings where you want to insert spaces.
Syntax:
<code>表达式1 || ' ' || 表达式2</code>
Example:
Suppose we have two fields: FirstName
and LastName
. To concatenate these two fields and add a space, we can use the following query:
<code class="sql">SELECT FirstName || ' ' || LastName AS FullName FROM myTable;</code>
Output:
FullName |
---|
John Doe |
Jane Smith |
Mike Jones |
Additional examples:
<code class="sql">SELECT FirstName || ' ' || LastName AS FullName FROM myTable;</code>
<code class="sql">SELECT ' ' || FirstName || LastName AS FullName FROM myTable; SELECT FirstName || LastName || ' ' AS FullName FROM myTable;</code>
chr(10 )
Function: <code class="sql">SELECT FirstName || chr(10) || LastName AS FullName FROM myTable;</code>
The above is the detailed content of How to add spaces to Oracle splicing fields. For more information, please follow other related articles on the PHP Chinese website!