Page 1 of 1

Query not running

Posted: Thu Dec 30, 2010 4:00 am
by dheeraja
Hi guys,

I am trying to run a MYSQL query having conditional statement, but it continuously showing me a error, please help me to come out.

QUERY:
IF 1 > 0 THEN
SELECT * FROM table1;
ELSE
SELECT * FROM table2;
END IF;
ERROR:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF 1 > 0 THEN
SELECT * FROM table1' at line 1
Thanks

Re: Query not running

Posted: Thu Dec 30, 2010 9:01 am
by phazorRise
Do mean something like this ...

Code: Select all

$result = mysql_query("SELECT * FROM example") 
?

Re: Query not running

Posted: Thu Dec 30, 2010 9:52 am
by Technical
Maybe you should do check in PHP?

Re: Query not running

Posted: Thu Dec 30, 2010 9:59 pm
by dheeraja
Firstly Thanks for your replies, and I am don't want to use any PHP code I will just directly run that query to MYSQL console. Actually I am trying to use conditional statements of MYSQL. I searched for that & I got but that all was not clear.