mahfuj asif :
Please consider the following table
|id| first_name| last_name| nick_name|
What is the best way to find names that matches certain value? Following query is working but is there any better way?
select * from names where first_name = val OR last_name = val OR nick_name = val
Can i do something like -
select * from names where first_name OR last_name OR nick_name = val
If not then why mysql does not allow to perform check on multiple attributes in a single condition?
Prabhjot Singh Kainth :
You can use IN function of MySQL.
MySQL IN() function finds a match in the given arguments.
select * from names where val IN(first_name,last_name,nick_name);
This won`t work :
select * from names where first_name OR last_name OR nick_name = val
As this will always result in false condition.