T tamadon Active Member Licensed User Longtime User Jun 6, 2012 #1 Say I have the following table score | someval ----- --------- 20 | 15 25 | 5 50 | 23 33 | 33 20 | 50 I want to delete min score which is 20 where someval is the lowest among the duplicates (if duplicate score exist). In the table above, it would be the first row. I think I know how to delete the min score record but the second condition I am not sure how to integrate into my query Code: Copy sqlScore.ExecNonQuery("DELETE FROM scorestable WHERE score = (SELECT min(score) FROM scores AND min(someval)") ??? Thank you for your help.
Say I have the following table score | someval ----- --------- 20 | 15 25 | 5 50 | 23 33 | 33 20 | 50 I want to delete min score which is 20 where someval is the lowest among the duplicates (if duplicate score exist). In the table above, it would be the first row. I think I know how to delete the min score record but the second condition I am not sure how to integrate into my query Code: Copy sqlScore.ExecNonQuery("DELETE FROM scorestable WHERE score = (SELECT min(score) FROM scores AND min(someval)") ??? Thank you for your help.
Erel B4X founder Staff member Licensed User Longtime User Jun 6, 2012 #2 See my code here: http://www.b4x.com/forum/basic4andr...s/11606-how-add-highscore-code.html#post64827 Upvote 0
See my code here: http://www.b4x.com/forum/basic4andr...s/11606-how-add-highscore-code.html#post64827
T tamadon Active Member Licensed User Longtime User Jun 6, 2012 #3 Thanks Erel. But what if we have several duplicate lowest scores, how does the code select which one is the older one to delete? BTW, I have included a DateTime.Now column so I am comparing the age using that column. Upvote 0
Thanks Erel. But what if we have several duplicate lowest scores, how does the code select which one is the older one to delete? BTW, I have included a DateTime.Now column so I am comparing the age using that column.
Erel B4X founder Staff member Licensed User Longtime User Jun 6, 2012 #4 You should change the orderby clause to the score followed by the date. Upvote 0
T tamadon Active Member Licensed User Longtime User Jun 7, 2012 #5 Thanks Erel, but I am not too familiar with SQL Lite database. I already have the highscore working based on this code But now I am trying to delete a particular record based on the condition. How to format this statement correctly? Code: Copy sqlScore.ExecNonQuery("DELETE FROM scorestable WHERE score = (SELECT min(score) FROM scores AND min(someval)") Sorry if I am asking an obvious question.. :sign0085: Upvote 0
Thanks Erel, but I am not too familiar with SQL Lite database. I already have the highscore working based on this code But now I am trying to delete a particular record based on the condition. How to format this statement correctly? Code: Copy sqlScore.ExecNonQuery("DELETE FROM scorestable WHERE score = (SELECT min(score) FROM scores AND min(someval)") Sorry if I am asking an obvious question.. :sign0085: