问题
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