0

My query

$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)")

I'm getting error like this:

   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
Cœur
  • 34,719
  • 24
  • 185
  • 251

2 Answers2

1

fields can't have spaces in them. i recommend looking to see if it is maybe Church_id instead of "Church id". likewise for Student_name

xeo
  • 797
  • 2
  • 5
  • 25
  • 1
    *"fields can't have spaces in them"* - Not entirely true. It's not good practice but they are allowed. Just as long as they are ticked `\``. – Funk Forty Niner Mar 29 '17 at 13:44
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)")

The part

ON Church_details.Church id=Class_details.Church id

You used a space for the Church Id.. Does the table really have a column name with a space. IF It does, you should type it like this

Church_details.[Church Id]

My bet is that the table's column is Church_Id

Bennjoe Mordeno
  • 2,241
  • 1
  • 9
  • 19