9 messages in com.mysql.lists.mysqlHow do you specify all records in a W...
FromSent OnAttachments
a rancid amoeba07 Sep 1999 17:02 
Joshua Chamas07 Sep 1999 17:21 
a rancid amoeba07 Sep 1999 18:09 
Joshua Chamas07 Sep 1999 18:26 
Michael Widenius08 Sep 1999 05:54 
Jules Bean08 Sep 1999 07:11 
Clinton Gormley08 Sep 1999 07:40 
Martin Ramsch08 Sep 1999 08:27 
Michael Widenius08 Sep 1999 09:33 
Subject:How do you specify all records in a WHERE statement?
From:a rancid amoeba (ran@best.com)
Date:09/07/1999 05:02:02 PM
List:com.mysql.lists.mysql

Yeah, sounds kinda nuts, but I want to be able to use a generic SELECT... WHERE... statement that can do sporadic limiting.

Here's an example of what's going on:

SELECT * FROM Table1 WHERE Region='$region' AND State='$state' AND Country='$country'

The user provides input through drop-down boxes. It's possible that they may pick a region but no state or country, or they may ask for a country but no state or region (or a country and state, but no region... you get the idea).

So what I'm baffled about is what to set a variable to when I don't want the WHERE statement to limit by that particular field. Is this possible? I feel like there should be an easy answer so I must be looking so hard for it in the manual and related texts that I'm looking right past it.

I realize that I could customize the SELECT statement by doing a bunch of if/then checks, but it's such a messy solution (and my SELECT statement is already pretty messy because I'm using several tables...the example above is way oversimplified).

Thanks for whatever help you can give me!

chanel