That's up to you of course. Personally, I think some things are better
handled by the database and some are better handled by the programming
language. Things like conditional logic tend to be best handled by the
programming language in my view. Your mileage may vary ;-)

After all, just because something might possibly be done by MySQL doesn't
mean it is the *best* place to do it. For example, a database can store
BLOBs like photographs or wave files; does that mean databases should be
used to *create* those files? In my view, the answer is no: you use graphics
programs to create pictures and music programs to create music.

Rhino
----- Original Message ----- 
From: "Luke Venediger" <[EMAIL PROTECTED]>
To: "Rhino" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, October 27, 2004 5:47 PM
Subject: Re: Select with an IF statements


> Hi Rhino,
>
> I don't think that answer solves the problem. I do use a programming
> language, and doing a query like this means I can make use of the
> database engine and not add overhead to my application.
>
> Cheers,
> Luke Venediger.
>
> On Wed, 27 Oct 2004 17:26:56 -0400, Rhino <[EMAIL PROTECTED]> wrote:
> >
> > ----- Original Message -----
> > From: "Luke Venediger" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, October 27, 2004 4:58 PM
> > Subject: Select with an IF statements
> >
> > > Hi,
> > >
> > > I'm trying to do the following:
> > >
> > > SELECT
> > >   IF((ProductStatus IS NOT NULL), "Available", "Not Available") as
> > ProductStatus
> > > FROM
> > >   tb_Product
> > > WHERE
> > >   ProductName = "MyProduct";
> > >
> > > It works fine if the ProductName "MyProduct" works, and returns
> > > "Available". However, if the product name doesn't work the query
> > > doesn't return any rows. I would like it to return "Not Available" if
> > > the product isn't found.
> > >
> > > Is there a better way to do this?
> > >
> > Yes; use a programming language like Java, Perl or PHP.
> >
> > Rhino
> >
> >
>
>
> -- 
> 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]
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to