Ich habe eine Anforderung, um Benutzer Vorname und Nachname mit Leerzeichen dazwischen in Oracle concat. Beispiel: Vorname ist 'Hopkins'
und Nachname ist 'Joe'
.
Der vollständige Name sollte als Hopkins Joe gedruckt werden.
Ich verwende Oracle 11g und es funktioniert in SQL-Abfragen, aber nicht in gespeicherten Prozeduren.
Versuche dies:
SELECT CONCAT(CONCAT(first_name, ' '),last_name)
ODER
SELECT first_name || ' ' || last_namefrom;
Versuche dies
select first_name || ' ' || last_name as full_name from table
Beispiel:
SELECT 'Dave' || ' ' || 'Anderson' as full_name
FROM table;
Result: 'Dave Anderson'
Die CONCAT-Funktion muss nicht zweimal verwendet werden. Concat with space wird auf diese Weise funktionieren
SELECT CONCAT(first_name,(' '||last_name)) AS full_name
Das wird funktionieren:
select first_name||' '||last_name
from table_name
where first_name is not null -- "if the first_name can be null"
and last_name is not null -- "if the last_name can be null"
;