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
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)
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
[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
, 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
,'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
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
, 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
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
).
/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
10 matches
Mail list logo