What is this Site!!

All about Real time requirements in Orale Stay Tune!!

Friday, February 8, 2008

SQL Server


>>Previous>>


Combining Search Conditions


As the previous example demonstrates, one can combine search conditions. But one need to be cautious when combining search conditions if one isn't familiar with Boolean logic: Don't confuse the AND and OR conditions.

Suppose someone say, "Get me a list of all our authors from Utah and Texas." One knows what one want.

But if one write the query as---


SELECT au_fname, au_lname, phone, au_id
FROM authors
WHERE state LIKE 'ut' AND state LIKE 'tx'


The query will not return any data because it asked for all authors who live in both Utah and Texas. The result you want is data that meets both conditions, authors who live in either Utah or Texas.

Instead, use this query:


SELECT au_fname, au_lname, phone, au_id
FROM authors
WHERE state LIKE 'ut' OR state LIKE 'tx'


Note that one needs to repeat the search condition. One can't write WHERE state LIKE 'ut' OR 'tx' because SQL Server expects a complete search condition on either side of the OR.



>>>Next>>>


2 comments:

shaik shah said...

Brilliant blog I visit this blog it's incredibly awesome. Curiously, in this blog content formed doubtlessly and sensible. The substance of information is helpful.
Oracle Fusion HCM Online Training
Oracle Fusion Financials Online Training

Rainbow Training Institute said...

Really very helpful article , Thank you for sharing

Big Data and Hadoop Online Training
Big Data Hadoop Training
Hyderabad