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

Recommended Answers

All 3 Replies

Member Avatar for diafol
"SELECT * FROM table WHERE '$trimmed' IN (street,number,first_name,last_name)";

Not tested

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%'";

Thanks for your replies i've solved it with your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.