jeudi 28 janvier 2016

MSQL IF statement Error

I'm trying to retrieve data of multiple parameters from a table of a MySQL based database.

I want check the count of date and if the count is equal to 24, I need to find max and min of multiple parameter and retrieve the data. I've used the below shown query, but it gives syntax error.

"SET @cnt=(select count(DATE) from DATA where ID=1111 and     DATA_DATE>='2016-01-24 00:00:00' and DATA_DATE<'2016-01-25 00:00:00')    \
       IF (@cnt=24) then \
            select MIN(parameter1),max(parameter2) from STATION_DATA where STATION_ID=6216 and DATA_DATE>='2016-01-24 00:00:00' and DATA_DATE<'2016-01-25 00:00:00' \
     END IF

But it gives syntax error . I'm a MySQL beginner and any help will be highly appreciated.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire