Skip to Content
author's profile photo Former Member
Former Member

Diff btwn AND & OR in WHERE clause?

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 09, 2007 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 09, 2007 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.