简体   繁体   中英

PHP MySQL select 2 columns where 1 column

im trying to select * from table1 where forename, surname = 'Joe Bloggs'

obviously forename and surname are 2 different columns in table one but im getting errors when i run this SQL code:

SELECT * from table1 where forename, surname = 'Joe Bloggs'

Any ideas on what i can do?

maybe you mean

SELECT * from table1 where CONCAT_WS(' ',forename, surname) = 'Joe Bloggs'

OR

SELECT * from table1 where 'Joe Bloggs' IN (forename, surname)

OR

SELECT * from table1 where forename = 'Joe' AND surname = 'Bloggs'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM