Query not running

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dheeraja
Forum Commoner
Posts: 36
Joined: Tue Nov 09, 2010 11:03 pm

Query not running

Post 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
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: Query not running

Post by phazorRise »

Do mean something like this ...

Code: Select all

$result = mysql_query("SELECT * FROM example") 
?
User avatar
Technical
Forum Commoner
Posts: 81
Joined: Thu Dec 02, 2010 5:30 am

Re: Query not running

Post by Technical »

Maybe you should do check in PHP?
dheeraja
Forum Commoner
Posts: 36
Joined: Tue Nov 09, 2010 11:03 pm

Re: Query not running

Post 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.
Post Reply