vendredi 20 mars 2015

Create a mysql routine cursor with a select in a select

I have a table like the following:



id gnome dead
-----------------
1 pet yes
2 pet no
3 pet no
4 kin no
5 kin yes
6 kin no


Now, I'd like to create a cursor in a routine taking:


1) all the rows where "dead" is "yes";


2) rows where "dead" is "no" only if there are no "dead" = "yes" for the same "gnome" before.


The result should be:



id gnome dead
-----------------
1 pet yes
4 kin no
5 kin yes

Aucun commentaire:

Enregistrer un commentaire