Compare value with concatenated fields in the where section

Say I want to find the user "Richard Best". Can I compare the full name associated with the first and last name? I do not have a full name field.

select * from users where last_name + ' ' + first_name like '%richa%' 

I am using mysql

+4
source share
3 answers

They are equivalent:

 select * from users where concat(last_name,' ',first_name) like '%richa%' select * from users where concat_ws(' ',last_name,first_name) like '%richa%' 

This may also work:

 select * from users where last_name like '%richa%' or first_name like '%richa%' 
+9
source
+4
source
 select * from users where (first_name + ' ' + last_name) like '%richa%' 
0
source

Source: https://habr.com/ru/post/1341187/


All Articles