Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Diff btwn AND & OR in WHERE clause?

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos

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

2 REPLIES 2

gopi_narendra
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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