mtvaran Posted December 2, 2010 Share Posted December 2, 2010 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 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 2, 2010 Share Posted December 2, 2010 Which StudentID do you want to use. You're referencing 2 in the query. Ken Quote Link to comment Share on other sites More sharing options...
mtvaran Posted December 2, 2010 Author Share Posted December 2, 2010 i need to use the StudentID from take table Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 2, 2010 Share Posted December 2, 2010 So identify it like you did two lines above that one. You probably have to identify which one you want in the "order by" clause also. Ken Quote Link to comment Share on other sites More sharing options...
mtvaran Posted December 3, 2010 Author Share Posted December 3, 2010 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); ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted December 3, 2010 Share Posted December 3, 2010 Does the query succeed and return 0 results, or does it fail? Quote Link to comment Share on other sites More sharing options...
mtvaran Posted December 3, 2010 Author Share Posted December 3, 2010 yes now it works. i had to take echo mysql_error(); off. previously i put it for error finding. thanks guys for your kind help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.