There is a structure to use sql query. you first have to Select Something From Table Join Other tables Filter with Where. Then you can Group the selects and then Order the results. In your question you simply used where after you used from so it is giving an error