Re: Syntax for Compound "IF" Statements?

2005-02-08 Thread SGreen
"Sue Cram" <[EMAIL PROTECTED]> wrote on 02/08/2005 01:18:48 AM: > Thanks to the people who helped me with my IF statement question > last night. Now I need to carry it one step further to a compound > 'IF' statement. Again, can't find much information in the manuals -- > > Several people sent

Re: Syntax for Compound "IF" Statements?

2005-02-08 Thread Ian Sales (DBA)
Harald Fuchs wrote: That's correct, but it can be written shorter and clearer: CASE Lccation WHEN 1 THEN 'Downstairs Cat Room' WHEN 2 THEN 'Kitten Room' WHEN 3 THEN 'Quarantine' ELSE 'Unknown' END AS Location - surely it would be better to have the location ids and location names in a lookup ta

Re: Syntax for Compound "IF" Statements?

2005-02-08 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Johan Höök <[EMAIL PROTECTED]> writes: > Hi, > I guess your "CASE" statement should look something like: > CASE WHEN Location=1 THEN 'Downstairs Cat Room' > WHEN Location=2 THEN 'Kitten Room' > WHEN Location=3 THEN 'Quarantine' > ELSE 'Unknown' EN

Re: Syntax for Compound "IF" Statements?

2005-02-08 Thread Gabriel PREDA
I didn't found an IF ... ELSE ... in MySQL ... and I'm using it for at least 4 years !... since the old 3.23.xx times !!! So you will have to do: SELECT a,b,c, IF(Location=1, 'Downstairs Cat Room', IF(Location=2, 'Kitten Room',

Re: Syntax for Compound "IF" Statements?

2005-02-08 Thread Johan Höök
Hi, I guess your "CASE" statement should look something like: CASE WHEN Location=1 THEN 'Downstairs Cat Room' WHEN Location=2 THEN 'Kitten Room' WHEN Location=3 THEN 'Quarantine' ELSE 'Unknown' END AS Location /Johan Sue Cram wrote: Thanks to the people who helped me with my IF state

Re: Syntax for Compound "IF" Statements?

2005-02-07 Thread David Blomstrom
I did a lot of homework on IF statements recently. Below are copies of some of the scripts I'm using now. This first example draws on a database filled with the names of the world's continents, oceans, nations and states, each given an ID in a field named IDArea. Each page on my site h

Syntax for Compound "IF" Statements?

2005-02-07 Thread Sue Cram
Thanks to the people who helped me with my IF statement question last night. Now I need to carry it one step further to a compound 'IF' statement. Again, can't find much information in the manuals -- Several people sent me "IF (Adopted=1, 'Y', 'N') AS Adopted FROM Animal" and it works great.

Re: Select with an IF statements

2004-10-28 Thread Jay Blanchard
[snip] 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 ;-) [/snip] AT the risk

Re: Select with an IF statements

2004-10-27 Thread Rhino
e 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 statem

Re: Select with an IF statements

2004-10-27 Thread Luke Venediger
]> 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 t

Re: Select with an IF statements

2004-10-27 Thread Luke Venediger
Thanks Paul! Luke Venediger. On Wed, 27 Oct 2004 16:17:51 -0500, Paul DuBois <[EMAIL PROTECTED]> wrote: > At 22:58 +0200 10/27/04, Luke Venediger wrote: > >Hi, > > > >I'm trying to do the following: > > > >SELECT > > IF((ProductStatus IS NOT NULL), "Available", "Not Available") as > >ProductSt

Re: Select with an IF statements

2004-10-27 Thread Rhino
- 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((ProductSta

Re: Select with an IF statements

2004-10-27 Thread Paul DuBois
At 22:58 +0200 10/27/04, Luke Venediger wrote: 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 "Availabl

Select with an IF statements

2004-10-27 Thread Luke Venediger
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

Re: Question about IF statements...

2004-01-14 Thread Cory Hicks
That did the trickthanks so much! Cory On Wed, 2004-01-14 at 12:50, Douglas Sims wrote: > Would something like this do what you want? > > SELECT project_id, SUM(time_worked) AS total FROM time_daily WHERE > user_id='clh' AND period_id='27' GROUP BY project_id HAVING total>0; > > > > Cor

Re: Question about IF statements...

2004-01-14 Thread Douglas Sims
Like this: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.0.13 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. umysql> use test; Reading table information for completion of table and column names You can turn off this fea

Re: Question about IF statements...

2004-01-14 Thread Douglas Sims
Would something like this do what you want? SELECT project_id, SUM(time_worked) AS total FROM time_daily WHERE user_id='clh' AND period_id='27' GROUP BY project_id HAVING total>0; Cory Hicks wrote: Hello, I must be having a goober moment.I am running the following sql query with no probl

RE: Question about IF statements...

2004-01-14 Thread Mike Johnson
From: Cory Hicks [mailto:[EMAIL PROTECTED] > Hello, > > I must be having a goober moment.I am running the following sql > query with no problems: > > SELECT project_id, > IF (SUM( time_worked ) > '0.00', SUM( time_worked ),'NULL') AS total > FROM time_daily > WHERE user_id = 'clh' AND period

Question about IF statements...

2004-01-14 Thread Cory Hicks
Hello, I must be having a goober moment.I am running the following sql query with no problems: SELECT project_id, IF (SUM( time_worked ) > '0.00', SUM( time_worked ),'NULL') AS total FROM time_daily WHERE user_id = 'clh' AND period_id = '27' GROUP BY project_id However, having 'NULL' appear

if statements

2002-03-01 Thread Forer, Leif
I'm performing a query on 2 tables: mysql> SELECT log.id, SUM (log.hours), empnum.lname > FROM log, empnum > WHERE log.id = '26009' > AND log.id=empnum.id > GROUP BY hours; Empty set (0.01 sec) The log table contains id numbers (plus a bunch of other data) but no corresponding names. The name

while...if statements???

2001-12-18 Thread Jay Fitzgerald
Does anyone know why this isn't working?? What I am trying to do is display photos from a database based on each month. This part works fine when I set it to the current month of December (today) as that is when I uploaded the photos. However, when I manually set the date to a month that has n

Re: nested if statements allowed?

2001-08-15 Thread Benjamin Pflugmann
Hi. On Tue, Aug 14, 2001 at 01:31:04PM -0700, [EMAIL PROTECTED] wrote: > I am trying to do a nested if, but it appears to break my query... > Here is a sample of what I am trying to, basically validating email > addresses out of a db: > > select IF( (LENGTH( emailaddr ) <= 1 || > NOT LOCATE( "

nested if statements allowed?

2001-08-14 Thread Eric Schultz
I am trying to do a nested if, but it appears to break my query... Here is a sample of what I am trying to, basically validating email addresses out of a db: select IF( (LENGTH( emailaddr ) <= 1 || NOT LOCATE( "\@",emailaddr ) || LOCATE( " ",emailaddr ), (IF address.ts >= 2001081300,