10-09-2007 1:56 AM
Hi Experts,
Pls. clarify my simple doubt in SQLs WHERE clause, abt AND & OR use!!
my code is:
<i><b>1) where ( erdat in s_aedat
or aedat in s_aedat ).------>100 recs fetched
2)where erdat in s_aedat
or aedat in s_aedat .
3) where erdat in s_aedat
and aedat in s_aedat . -
>70 recs fetched</b></i>
thanq.
10-09-2007 2:18 AM
1) where ( erdat in s_aedat
or aedat in s_aedat ).------>100 recs fetched
In case 1 it does not need to satisfy both the conditions, either of the conditions satisfies and the record is retrieved.
ie if in the table there is value for erdat in s_aedat OR if there is a value for aedat in s_aedat the record is retrieved
2)where erdat in s_aedat
or aedat in s_aedat .
Case 2 is same as case 1
3) where erdat in s_aedat
and aedat in s_aedat . -
>70 recs fetched
In case 3 it need to satisfy both the conditions, only when both the conditions satisfies and the record is retrieved.
ie if in the table there is value for erdat in s_aedat AND if there is a value for aedat in s_aedat the record is retrieved, here if the data in the table matches for both the fields with the value given on the selection screen only the record is shown
Hope this is clear.
Regards
Gopi
10-09-2007 2:18 AM
1) where ( erdat in s_aedat
or aedat in s_aedat ).------>100 recs fetched
In case 1 it does not need to satisfy both the conditions, either of the conditions satisfies and the record is retrieved.
ie if in the table there is value for erdat in s_aedat OR if there is a value for aedat in s_aedat the record is retrieved
2)where erdat in s_aedat
or aedat in s_aedat .
Case 2 is same as case 1
3) where erdat in s_aedat
and aedat in s_aedat . -
>70 recs fetched
In case 3 it need to satisfy both the conditions, only when both the conditions satisfies and the record is retrieved.
ie if in the table there is value for erdat in s_aedat AND if there is a value for aedat in s_aedat the record is retrieved, here if the data in the table matches for both the fields with the value given on the selection screen only the record is shown
Hope this is clear.
Regards
Gopi
10-09-2007 2:49 AM
Hi Srikhar,
I think just by wording you can guess it.
OR -> any one condition true
AND-> you need to have both condition true.
Hence it will always be less or same record in AND compare to OR.
Regards,
Atish