How Do I Get Select Statement To Return Correct Results?

See select statement below. I am not getting the expected results. We need:
Requirements:
1. Must enter the Date Range, you enter PrLine Only - Get results
2. Must enter the Date range, you enter Desc only - Get Results
3. Must enter the Date Range, you enter PrLine and Desc  - Get Results

Can the requirements be met with one select Statement?

SELECT *
FROM BidsAndNotesFINAL
WHERE (BidDetailFinal_PrLine LIKE '%PriceLine%') OR (BidDetailFinal_Desc LIKE '%Desc%') AND (BidDetailFinal_OrdDate BETWEEN #varStartRange# AND #varEndRange#)
ES-ComponentsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Try Parenthesizing the first two expressions -- open parenthesis to the right of "WHERE" and close parenthesis to the left of "AND":
SELECT *
FROM BidsAndNotesFINAL
WHERE ( (BidDetailFinal_PrLine LIKE '%PriceLine%') OR (BidDetailFinal_Desc LIKE '%Desc%') ) AND (BidDetailFinal_OrdDate BETWEEN #varStartRange# AND #varEndRange#)
0
ES-ComponentsAuthor Commented:
Your suggestion did not work. If I enter just the PrLine and Date Range I do not get the resuslts.

In your suggestion, if I enter PrLine and Desc and Date range it works.

I am beginning to think that I will need three separate query statements. I am not sure if I can do what we need in just one statement.
0
hieloCommented:
>> In your suggestion, if I enter PrLine and Desc and Date range it works.
OK, take a close look at your results.  It must be matching the Date range, but do any of the results have the PrLine you entered?  I suspect it is matching only Desc AND Date range.

In other words, if you retry that working query (where you entered all three terms) and you then omit the PrLine portion, you still get the same number of records as when you entered all three, correct?  If so, then the query is correct.  You just don't have records where PrLine matches that date range.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ES-ComponentsAuthor Commented:
tHANK YOU....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.