PHP MySQL选择2列,其中1列

时间:2013-05-15 14:02:30

标签: mysql sql

我试图从table1中选择* forename,surname ='Joe Bloggs'

显然forename和surname是表1中的2个不同的列,但是在运行此SQL代码时出现错误:

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

关于我能做什么的任何想法?

1 个答案:

答案 0 :(得分:5)

也许你的意思是

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'