mysql - COUNT not working in Query with JOIN (SQL) -


I tried to add a COUNT to my MySQL query, because I want the amount of all the rows .

Original: SELECT a. *, B.device_name, FROM (ID select from DESC 500 by qslist order) a. Devices = B.ID

New: SELECT a. *, B.device_name, as a.COUNT (ID) from a join device b on A device (from selection * to qslist order by IDSEC Ltd. 500) = B.ID

< P> Unfortunately, the new query has not been executed, the following error message is shown:

# 1064 - You have an error in your SQL syntax; To use the nearest FROM (SELECT * FROM qslist Order ID IDEC Ltd 500) near a join device b on line '1 line', check the manual related to your MySQL server version for the correct syntax .

What's the problem here?

outside is a reserved word in MySQL, or you can save it Can give some more names:

  SELECT a. *, B.device_name, COUNT (a.id) from AS cnt (Select * ID by DESC 500 500 by qslist command) a.device = b.id on an added tool b;  

Additionally, a. Goes ahead of id , no count () .

This syntax fixes the error.

This query is not likely to work as you wish, because it will return only one line count () makes it a combination query with is. However, your question is about syntax error, not the right query for your unstable purposes. (If you want to fix the query, then I suggest asking another question with sample data and the desired result.)


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -