Complex conditional statement during select

2008-08-28 Thread Jay Blanchard
SELECT this, that, theOther, SUM(IF(SUBSTRING(myDate,1,10) = '20080101' AND SUBSTRING(myDate,1,10) = '20080131'), 1, 0) AS `January` FROM theTable GROUP BY theOther Throws this error... ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL

Re: Complex conditional statement during select

2008-08-28 Thread DuĊĦan Pavlica
Try this: SELECT this, that, theOther, SUM(IF(SUBSTRING(myDate,1,10) = '20080101' AND SUBSTRING(myDate,1,10) = '20080131', 1, 0)) AS `January` FROM theTable GROUP BY theOther Problem was in parentheses Dusan Jay Blanchard napsal(a): SELECT this, that, theOther, SUM(IF(SUBSTRING(myDate,1,10)

Conditional statement: IF

2004-10-22 Thread Luke Venediger
Hi, 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

RE: **[SPAM]** Conditional statement: IF

2004-10-22 Thread Jay Blanchard
[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

Re: Conditional statement: IF

2004-10-22 Thread Rhino
, I'm pretty sure you can't put ifs around your SQL. Rhino - Original Message - From: Luke Venediger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 22, 2004 10:31 AM Subject: Conditional statement: IF Hi, I'm trying to write a conditional statement in my query

Re: Conditional statement: IF

2004-10-22 Thread Anders Karlsson
,'It is 1', 'It is not one'); But I suspect you want something more advanced than this, as this is not the most useful program the world has seen. (But not the least useful either). /Karlsson Luke Venediger wrote: Hi, I'm trying to write a conditional statement in my query. Is the following

Re: Conditional statement: IF

2004-10-22 Thread Luke Venediger
program the world has seen. (But not the least useful either). /Karlsson Luke Venediger wrote: Hi, 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

Re: **[SPAM]** Conditional statement: IF

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

Re: **[SPAM]** Conditional statement: IF

2004-10-22 Thread SGreen
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

Re: Conditional statement: IF

2004-10-22 Thread Anders Karlsson
). /Karlsson Luke Venediger wrote: Hi, 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