| Author |
Topic |
|
nssjari
Starting Member
46 Posts |
Posted - 2005-07-06 : 08:57:06
|
| To select few fields from respective table depending on the value of the field and according apply condition of the where clause.select a, b, c, d, e, fI mean if a value of the field d in select clause is not null then do check for a where clause expression1 and expression2 else do check only for the where clause expression1 onlyAlso if a value of the field d in select clause is null,it should not select d, e, fIs this possible in SQL or PL/SQL if so whats the SQL syntaxPlease do reply ASAPJariJariComputer Engg |
|
|
Crito
Starting Member
40 Posts |
Posted - 2005-07-06 : 09:05:11
|
| your where clause would look something like:WHERE (Field1 = X OR Field1 IS NULL)AND(Field2 = X OR Field2 IS NULL)etc...----------------------------------Gun for hire, have horse, will travel. |
 |
|
|
nssjari
Starting Member
46 Posts |
Posted - 2005-07-06 : 09:14:46
|
| I need to apply this logic to the question posted below ..."select a, b, case when exp then c, d try if u can ... nssjari"Please have a look at this problem if you can spare a little time ...JariComputer Engg |
 |
|
|
Crito
Starting Member
40 Posts |
Posted - 2005-07-06 : 09:20:53
|
| Looks like you answered your own question: use a case statement in your select clause.----------------------------------Gun for hire, have horse, will travel. |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-07-06 : 09:22:27
|
| Your SELECT statement will always return a constant number of columns. You cannot conditionally return a col.umn though you can return Null for that column. If you want to return two versus three columns, put that logic into an IF statement.HTH=================================================================None are more hopelessly enslaved than those who falsely believe they are free. -Johann Wolfgang van Goethe, poet, dramatist, novelist, and philosopher (1749-1832) |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-07-06 : 09:33:44
|
| "Is this possible in SQL or PL/SQL if so whats the SQL syntax"This translates to "I do not wish to learn to do crap for myself: " + 1) Do my homework for me nowOR2) Do my open book test for me nowOR3) Do my job for me nowIf I am wrong, my apologies. Otherwise, feel free to go pound sand.*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
 |
|
|
Crito
Starting Member
40 Posts |
Posted - 2005-07-06 : 09:43:53
|
| Methinks Don needs to switch to decaf... LOL----------------------------------Gun for hire, have horse, will travel. |
 |
|
|
nssjari
Starting Member
46 Posts |
Posted - 2005-07-06 : 09:44:44
|
Hey thats cool ...You are very smart ... is that what you feel ... HahahahaI am seriously asking something if you can look into it ...nobody is forcing anybody here right dear ...Anyways nice to hear from you ... Thanks a lot For you philosophical query ... Your friend Jariquote: Originally posted by DonAtWork "Is this possible in SQL or PL/SQL if so whats the SQL syntax"This translates to "I do not wish to learn to do crap for myself: " + 1) Do my homework for me nowOR2) Do my open book test for me nowOR3) Do my job for me nowIf I am wrong, my apologies. Otherwise, feel free to go pound sand.*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected)
JariComputer Engg |
 |
|
|
nssjari
Starting Member
46 Posts |
Posted - 2005-07-06 : 09:49:55
|
Hey I am sorry if I am troubling you ...Actually it relates very much to a query already posted ...So if you look at it ... you would know what i am asking for ...Anyways love you friend for sparing your presious time for me...Wish you all the best for your future ...Your good friend ... Jariquote: Originally posted by Crito Methinks Don needs to switch to decaf... LOL----------------------------------Gun for hire, have horse, will travel.
JariComputer Engg |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-07-06 : 10:17:23
|
I do drink decaf The way the questions are worded just sound like that to me is all. No code attempts, no DDL, no nothing.*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
 |
|
|
|