Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
select one record for the first matching condition only in four where
I need your suggestion to write one tricky SQL query to select only one record from database on the following condition.I explained simple table structure below.I have a table temp with four columns a,b,c,d in it.
I have to select column d from this temp table based on the following four conditions.If it matches any condition, It should skip other conditions, that's the tricky thing.
Conditions order is like shown below.
1) a='argument1' and b='argument2' and c='argument3'(If it matches this condition, it should stop selecting below 3 conditions)
2) a='argument1' and b='argument2' and c='none'(If it matches this condition, it should stop selecting below 2 conditions)
3) a='argument1' and b='none' and c='argument3'(If it matches this condition, it should stop selecting below condition)
4) a='argument1' and b='none' and c='none'(this is last condition)
If I use OR operator , it matches all of those other conditions too.I never wrote query like this before.
I greatly appreciate if somebody sheds light on me to start writing this query with a simple suggestion.
0 · ·