What would be the php mysql code to search more than 1 field in a table ?

Im trying to search for a given partial phone number in all three fields home mobile and work ..

im trying to use

$query = "SELECT `first`, `last`, `home_phone` , `work_phone` , `mobile_phone` FROM `profiles` WHERE LIKE '%516353%'

but this returns everything thats in the table

Any help would be appreciated

Recommended Answers

All 3 Replies

$query = "select * from table where home_phone like '%516%' OR work_phone like '%516%' OR mobile_phone like '%516%'";
$query = "select * from table where home_phone like '%516%' OR work_phone like '%516%' OR mobile_phone like '%516%'";

thatnk it worked fine i just had to change OR TO ||

:) It should work with OR.. But anyway, cheers!

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.