1

I am creating a query like the following

SELECT CONCAT(u.firstName," ",u.lastName) as user

then later on in the query I write:

WHERE user LIKE '%jay%'

I am getting no results. Are you not able to use a concatenated field this way?

Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94
user1214633
  • 647
  • 1
  • 6
  • 6

1 Answers1

3
SELECT CONCAT(u.firstName," ",u.lastName) as user ... WHERE user LIKE '%jay%'

will not work, but

SELECT CONCAT(u.firstName," ",u.lastName) as user ... HAVING user LIKE '%jay%'

will work, as HAVING works on the results of the query, whereas WHERE does not.

Ross Smith II
  • 11,799
  • 1
  • 38
  • 43