Jump to content

if exists


xxreenaxx1

Recommended Posts

I am trying to run this query on a webpage but I am getting an error. So I tested this on mysql and this is giving me error as well.

 

#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 EXISTS(SELECT * FROM user u, subject s, test t, question q, answer a WHERE u.' at line 1

 

IF EXISTS
(SELECT * FROM user u, subject s, test t, question q, answer a WHERE u.Use_ID = 1
    AND t.Sub_ID = 1
AND s.Sub_ID = t.Sub_ID
AND q.Que_ID = a.Que_ID)

 

am I doing anything wrong.

Link to comment
https://forums.phpfreaks.com/topic/232155-if-exists/
Share on other sites

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM user u, subject s, test t, question q, answer a WHERE u.Use_ID = 1
    AND t.Sub_ID = 1
    AND s.Sub_ID = t.Sub_ID
    AND q.Que_ID = a.Que_ID", $link);

$num_rows = mysql_num_rows($result);

if($num_rows)
{
}
else
{
}

 

Link to comment
https://forums.phpfreaks.com/topic/232155-if-exists/#findComment-1194342
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.