Jump to content

how to fix "where clause is ambiguous" error!!


mtvaran

Recommended Posts

hi guys how to fix this error. i have this query

$sql = "
    SELECT take.StudentID
          ,student.StudentName
          ,take.CourseID
          ,course.CourseName
    FROM take
        ,student
        ,course
    WHERE take.StudentID = student.StudentID
    AND take.CourseID = course.CourseID
    AND StudentID LIKE '$_POST[sid]%'
    ORDER BY StudentID ASC
";

$result = mysql_query($sql) or trigger_error('MySQL Error: ' . mysql_error(), E_USER_ERROR);

 

 

 

error msg: Fatal error: MySQL Error: Column 'StudentID' in where clause is ambiguous in C:\wamp\www\dis_take.php on line 98

 

Link to comment
Share on other sites

this is my full query for searching data from multiple table. still i could not get any result. could anyone check please where am i made mistake?

<?php  

	$con = mysql_connect("localhost","root","");
if (!$con)
  	{
  	die('Could not connect: ' . mysql_error());
  	}

mysql_select_db("uni", $con);

$sql = "
    SELECT take.StudentID
          ,student.StudentName
          ,take.CourseID
          ,course.CourseName
    FROM take
        ,student
        ,course
    WHERE take.StudentID = student.StudentID
    AND take.CourseID = course.CourseID
    AND take.StudentID LIKE '$_POST[sid]%'
    ORDER BY take.StudentID ASC
";

$result = mysql_query($sql) or trigger_error('MySQL Error: ' . mysql_error(), E_USER_ERROR);

echo"<br>";

echo "<center><table width=700 border=1>";
echo "<tr><th>StudentID</th><th>StudentName</th><th>CourseID</th><th>CourseName</th></tr>";

while($row = mysql_fetch_array ($result))
echo mysql_error();
{

echo "<tr><td>";
echo $row['StudentID'];
echo "</td><td>";
echo $row['StudentName'];
echo "</td><td>";
echo $row['CourseID'];
echo "</td><td>";
echo $row['CourseName'];
echo "</td></tr>";

}

echo "</table>";

mysql_close($con); 
?>

 

 

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.