By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Stuck with WHERE clause with multiple elements

P: n/a
Hi

I'm a bit stuck with a SELECT query. This is a simplified version of
what I need. I've had a look in a few books and online but I'm
definitely missing something. I'm trying to avoid looping and cursors.
I'll be running this in a stored procedure on SQL 7.

I have a separate query which returns a series of numbers, A, say 101
103 107 109 113.

I have a table (tableB) with a field myFieldB where I have another
series of numbers, B. I want return each row in tableB where
i - ALL values in A exist
ii- ANY values in A exist

For ii, I can use WHERE myFieldB IN A

How about for i?

Is there a good guide on the web or a book on WHERE clauses and/or
more complex SQL?

Thanks in advance!

Sam
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Samuel Hon (no*****@samuelhon.co.uk) writes:
I'm a bit stuck with a SELECT query. This is a simplified version of
what I need. I've had a look in a few books and online but I'm
definitely missing something. I'm trying to avoid looping and cursors.
I'll be running this in a stored procedure on SQL 7.

I have a separate query which returns a series of numbers, A, say 101
103 107 109 113.

I have a table (tableB) with a field myFieldB where I have another
series of numbers, B. I want return each row in tableB where
i - ALL values in A exist
ii- ANY values in A exist

For ii, I can use WHERE myFieldB IN A

How about for i?


I'm afraid I don't really follow. For one given row, myFieldB can only
hold one value, so how could it match all values in A?

I guess it's time for the usuual request. Please post:

o CREATE TABLE scripts for the tables involved.
o INSERT statements with sample data.
o The desired output give the sample data.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.