-1

We need to find median query in a database in MySQL.

I wrote the query:

SET @MED=ROUND((SELECT COUNT(*) FROM STATION)/2,0) ;
SELECT @MED;
SELECT LAT_N, LONG_W FROM STATION LIMIT @MED,1;

My med holds some value but this error is popping up:

ERROR 1064 (42000) at line 3: 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 '@MED,1' at line 1

Arulkumar
  • 12,153
  • 12
  • 44
  • 61
schwifty
  • 39
  • 7

0 Answers0