I have two tables one is students_Games and one is students tables both have a student_id a primary foriegn key relationship now based on their games I am putting them in some queue
Student table {Student_id,name,Address}
Students_games(id,Student_ID(FOREIGNKEY,game_code),
My Qyuery is like this
Select * from studnets ss
join students_games gg on gg.Student_id=ss.student_Id where gg.Games_code in (200,300)
Now when i run this for student id 2 and 3 it will return two,two rows one for 200 and one for 300 , now I want to set the prioirty like if there is 200 available then it must return 200, if not then it should return 300 if both of them not present then it should return 0 . how to query it like that i mean if 200 game code is available then chose it for every student and don't chose 300 for it if 200 is available if 200 is not available then chose 300 as game code if both of them not there then chose 0