Jump to content

mysql line is not working properly


swapnali_s230

Recommended Posts

Sorry for inconvenience.. Let me explain you...

$query =mysql_query("SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND Course_Name='COSC 3312' AND Course_Name='COSC 2430'");

$count=mysql_num_rows($query);echo $count;

 

If I try to echo count, it will give me 0. It is supposed to give me 1. That is how it is not working.

 

Course_Name='COSC 3312' AND Course_Name='COSC 2430'

 

Course_Name cannot be two different values at the same time. You actually need to use an OR condition to select the rows where Course_Name='COSC 3312' OR Course_Name='COSC 2430'.

 

Give the following query a try -

SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND (Course_Name='COSC 3312' OR Course_Name='COSC 2430')

 

Or even more simpler -

 

SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND Course_Name IN ('COSC 3312','COSC 2430')

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.