T-SQL style procedural scripting will not be initially available outside 
of stored procedures. Stored procedures are new to 5.0 (still under 
development) so what you want to code is not available, yet.  You will 
have to make program branch choices in a programming language as the SQL 
engine currently does not support that construction in ad hoc SQL scripts.

However, you were shown two methods by which a query can return optional 
values. Perhaps you can minimize your round-trips to the server by using 
one of those methods.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Luke Venediger <[EMAIL PROTECTED]> wrote on 10/22/2004 01:48:41 PM:

> Hi, 
> 
> Apologies, yes I have RTFM, and should've clarified my question. I
> actually need to do something more like this:
> 
> IF(@SomeValue = 1)
> BEGIN
> THEN
>   SELECT "Data" as Column1,
>                 "MoreData" as Column2
> ELSE
>   SELECT "SomeValue is not = 1" as Error
> END IF
> 
> Thanks,
> Luke Venediger.
> 
> 
> 
> On Fri, 22 Oct 2004 09:39:21 -0500, Jay Blanchard
> <[EMAIL PROTECTED]> wrote:
> > [snip]
> > I'm trying to write a conditional statement in my query. Is the
> > following possible in MySQL?
> > 
> > IF(@SomeValue = 1)
> > THEN
> >  SELECT "The value is 1";
> > ELSE
> >  SELECT "The value is not 1";
> > END IF
> > 
> > I've tried different variations and nothing seems to be working (I'm
> > getting syntax errors). I'm using MySQL 4.0.18. Any help would be
> > greatly appreciated.
> > [/snip]
> > 
> > Have you RTFM?
> > 
> > SELECT IF(@SomeValue = 1, 'The value is 1', 'The value is not 1')
> > 
> > http://dev.mysql.com/doc/mysql/en/Control_flow_functions.html
> > 
> 
> 
> -- 
> Get Firefox Browser! Reclaim the web. http://getfirefox.com/
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to