Bravo
Bravo

Reputation: 1139

How to perform a SELECT by adding two columns?

Assume I have a table called Person with columns name, surname and age.

I want to add two columns when performing a SELECT statment, probably something like this:

SELECT a FROM Person a WHERE a.name + a.surname LIKE ...

How can I do this correctly?

Upvotes: 1

Views: 31

Answers (3)

Lennart - Slava Ukraini
Lennart - Slava Ukraini

Reputation: 7171

|| is the standard concat operator:

SELECT a FROM Person a WHERE a.name || a.surname LIKE ...

Note that you must have PIPES_AS_CONCAT set for that to work. As others have mentioned there is also a concat function that can be used.

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1270081

You do not add string values, like names. Presumably, you want to concatenate them, so you use the concat() function:

where concat(a.name, a.surname) like . . .

Upvotes: 1

Emile P.
Emile P.

Reputation: 3962

SELECT a FROM Person a WHERE CONCAT(a.name, a.surname) LIKE ...

Upvotes: 1

Related Questions