我的查询
$con=mysqli_query($sql,"(SELECT Church Name, Class, Student Name, Mark FROM Church_details INNER JOIN Class_details ON Church_details.Church id=Class_details.Church id GROUP BY Class ORDER BY Student Name)")
我收到的错误是这样的:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'id=Class_details.Church id GROUP BY Class ORDER BY Student Name)' at line 1
答案 0 :(得分:1)
字段中不能包含空格。我建议看看它是否可能是Church_id而不是“Church id”。同样适用于Student_name
答案 1 :(得分:0)
SELECT Church Name, Class, Student Name, Mark
FROM Church_details INNER JOIN Class_details
ON Church_details.Church id=Class_details.Church id
GROUP BY Class
ORDER BY Student Name)")
部分
ON Church_details.Church id=Class_details.Church id
你为Church Id使用了一个空格。这个表是否真的有一个带有空格的列名。如果它,你应该像这样输入
Church_details.[Church Id]
我敢打赌,该表的列是Church_Id