Multiple Queries in mySQL in a single statement?

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
frogontop
Forum Newbie
Posts: 4
Joined: Sat Mar 13, 2004 10:59 pm

Multiple Queries in mySQL in a single statement?

Post by frogontop »

I'm trying to do an advanced search function with my database.
So far the only thing that works is a two field Search.
This is the sql statement.

SELECT *
FROM contacts
WHERE region LIKE '%region%' AND sport LIKE '%sport%'
ORDER BY sport ASC

What I really want to happen is (this is just theory so bear with me)

SELECT *
FROM contacts
WHERE region LIKE '%region%' AND sport LIKE '%sport%' AND level LIKE '%level%' AND genre LIKE '%genre%' AND name LIKE '%name%'
ORDER BY sport ASC

Is this possible or am I barking up the wrong tree... I'm just not sure how to search more than two fields in a database or the correct syntax if possible.

Any help would be greatly appreciated!
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

That should work.
frogontop
Forum Newbie
Posts: 4
Joined: Sat Mar 13, 2004 10:59 pm

Post by frogontop »

Yeah, it should've but it didn't. I figured out (I use Dreamweaver MX for graphical aspects) that dreamweaver was fudging up my sql statements, I switched over to notepad and things worked fine.
Post Reply