sql - mysql select query - to match one field with the other field -


i trying find records has following scenario.

id |     name   |      email  1      robert        robert@gmail.com  2      william       bill@gmail.com  3      michael       michael@gmail.com  4      micahel       mike@gmail.com 

based on above table, want find records "name" contained in "email field", here record 1 , 3 should output , not 2 , 4. there way can comparison?

i tried reading regex couldn't find anything. if it's comparison of same value, straightforward, not having clue one. thought of like looks cannot have field names.

the exact syntax depend on how want define relationship.

are looking name anywhere in email address? (this slow)

select id,name,email your_table email concat('%',name,'%') 

just @ beginning of email address?

select id,name,email your_table email concat(name,'%') 

just before @ sign?

select id,name,email your_table email concat(name,'@%') 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -