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.

 

Link to comment
Share on other sites

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')

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.