jeudi 23 avril 2015

IF entry in MySQL exists do

I am trying to query my database just under the condition that there is a session active. I want to solve that with an IF-Statement and I looked through these pages here for a nice solution, but nothing works out for me.

My current approach is this one:

IF (SELECT EXISTS (SELECT endtime
                   FROM session
                   WHERE userid = 0
                   AND sessionid = 1
                   AND endtime = -1))
BEGIN
//Do stuff here
END

Maybe somebody can help me out here?

I am running a MariaDB MySQL.

Cheers & Thanks.

Aucun commentaire:

Enregistrer un commentaire