0

Evening Sirs,

I would like to specialize my search script, by not only searching in one row, but in more. For example my mysql_query looks like this now:

$query = "select * from table where street = '$trimmed'";

I would like to query it like this:

$query = "select * from table where street,number,first_name,last_name = '$trimmed'";

I would really be thankful for the person who answered the right snippet for this issue.

Thanks in advance,

Tibor

3
Contributors
3
Replies
15
Views
4 Years
Discussion Span
Last Post by tibormarias
0
"SELECT * FROM table WHERE '$trimmed' IN (street,number,first_name,last_name)";

Not tested

Edited by diafol

0

The above works, provided the number column is a varchar, and the value in $trimmed has to be an exact match. So if that is not what you want, you'll have to split up the WHERE into separate parts. Most common is:

$query = "SELECT * FROM `table` WHERE `street` LIKE '%$trimmed%' AND `first_name` LIKE '%$trimmed%' AND `last_name` LIKE '%$trimmed%'";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.