Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
On Mon, 2010-11-29 at 20:04 -0500, Tom Metro wrote: > tbs wrote: > > What I was wondering is, can I do this : > > > > select t.a, t.b, t.c, t.d > > from table 't' > > where > > ta. = 'foo' > > and t.b = 'bar' > > IF (cond) THEN > > AND isNULL(t.c) > > ELSE > > AND t.c in(vINPUTLIST) > > ENDIF; > > It should be possible to avoid repeating the long SQL statement twice > using one of two possible techniques: > > 1. Write your WHERE clause using IF() or other functions (functions, not > flow control statements, as you show above) such that it always returns > true when the supplied vINPUTLIST is NULL. sounds like a good idea > > 2. Build your SQL as a string, as illustrated in this thread: > http://forums.mysql.com/read.php?98,395690,395690#msg-395690 > This is much as you would do in an application language, and in this > case you can use flow control statements. Though this approach might > subvert some of MySQL's optimizations. > yup, seems like the way to go, thanks for the pointers .. > > > well I have googled until my eyes are bleeding but cannot get a > > definitive answer on this one ... > > Try the MySQL Stored Procedures Forum: > http://forums.mysql.com/list.php?98 > > -Tom >
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |