0

I have a simple select statement in mysql written below, it keeps giving me a syntax error for the first + sign in the concatenation and I cannot figure out why, I also tried using the concat function and an error occurs as well.

select 1.VendorID, 1.VendorName, 1.VendorContactFName + " " + 1.VendorContactLName as Name
from Vendors as 1 JOIN
     Vendors as 2
     on 1.VendorID <> 2.VendorID and
        1.VendorContactFName = 2.VendorContactFName
order by Name; 
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709
Santi
  • 1

2 Answers2

2

First, don't use numbers as table aliases. Second, to concatenate strings, use concat(). Third, single quotes are the normal delimiter for strings.

So:

select v1.VendorID, v1.VendorName,
       concat(v1.VendorContactFName, ' ', v1.VendorContactLName) as Name
from Vendors as v1 JOIN
     Vendors as v2
     on v1.VendorID <> v2.VendorID and
        v1.VendorContactFName = v2.VendorContactFName
order by Name; 
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709
0

Have you tried it with the concat function instead?

CONCAT(1.VendorContactFName, ' ', 1.VendorContactLName) as Name

might be what you need. But I think it will return null if any of the parameters are null.