简体   繁体   中英

Cheking multiple columns in a table with single select query

I'm passing a value to the database(Say-'gupta'). I want to compare this value with all the columns present in the database table. If any column value matched the particular value then I want to simply print that row in my Php Page. Is there any inbuilt function to do this using select query.If yes please tell me. Remember i want to compare the passed value('gupta') with the multiple columns values in the database(corephp+mysql)

USE LIKE along with OR. eg.

Select * from table where (col1 like '%gupta%') or (col2 like '%gupta%')

so any col matches your input word, this will return the row.

只是一个主意

select * from TableName where "gupta" IN (ColumnOne,ColumnTwo,ColumnThree)

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