mysql searching

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
spartan7
Forum Commoner
Posts: 29
Joined: Sun Jun 19, 2005 12:09 am

mysql searching

Post by spartan7 »

I need to do a single keyword search that searches multiple columns in the same table (and across another table) for example :

Table> ID First Name, Last Name, Cel, Fax etc

I need to search all of those fields at once.

How do I use one search box/query to search for multiple records searching all those columns/fields at once?

Thanks
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Well, you can add restrictions on the returned rows with the WHERE clause.
And you can use AND and OR to add multiple restrictions...

Code: Select all

SELECT * FROM table WHERE col1='bar' OR col2='bar'
SELECT * FROM table WHERE col1='foo' AND col2='foo'
Post Reply