syntax error in mysql with php using inner join [closed]

不羁的心 提交于 2019-12-13 09:54:25

问题


i have a select query with inner join i try it in phpmyadmin it work fine

but when i try it in the browser it display this error msg :

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 'SELECT s.specialization_name FROM user u INNER JO' at line 1

the query is :

elseif($_POST['listbyq']=="by_specialization")

   {
      $querySrting="SELECT s.specialization_name FROM user u 
                             INNER JOIN specialization s 
                                         ON u.specialization=s.specialization_id";

      $result = mysql_query($querySrting)  or die("there is an error in this query");
      $queryMSG="showing members with specs";

回答1:


Since user is not a reserved word, there is most likely a foreign character that is causing the error (located near INNER JO).




回答2:


Just try:

$querySrting="SELECT s.specialization_name FROM user u INNER JOIN specialization s ON u.specialization=s.specialization_id";



回答3:


I tried it out in this fiddle, and seems to work fine. One thing that sometimes works, is removing all whitespace and writing it again (there might be a non-displayable character in there that is messing the query). Another thing, you spelled it "Srting", that reads like trouble in the future.



来源:https://stackoverflow.com/questions/16526038/syntax-error-in-mysql-with-php-using-inner-join

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!