Groups | Blog | Home
all groups > inetserver asp db > september 2004 >

inetserver asp db : Trying to figure out a Query


Guy Verville
9/29/2004 1:05:17 PM
Hi,

I have two tables. One contains Titles of Music. The other one contains
Scores. The relationship is based as follow:
Titles!TitlesID is linked with Scores!TitlesID (Many scores can exist for
the same title).

In the Scores table, there is also a field call "VisibleForWeb"
(True/False).

My problem is this one. I want to show only the titles that are visible for
the web, and I don't want duplicate names (e.g.: I have 30 Agnus Dei
different scores, but only 20 are allowed to be visible on the Web).

Hence, my SQL should read something like: Select Titles in "Titles" when in
"Scores" it's ok to show it.

It may be simple, but I'm lost...

Guy

Guy Verville
9/29/2004 1:25:22 PM
I can add that I have already a query that gives me only the scores that are
visible for the web. From that query, I would have like to have a list of
Titles with no duplicates in it.

Guy

"Guy Verville" <taddeus@spamcop.net> a écrit dans le message de news:
%23NU69ZkpEHA.3716@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Bob Barrows [MVP]
9/29/2004 2:53:50 PM
[quoted text, click to view]

I suspect you are using Access, but please don't make us guess. Always tell
us the type and version of database you are using.
In this example, I am going to make some guesses as to your fieldnames:

One way to do it is to use the DISTINCT keyword:

Select DISTINCT t.Titles FROM Titles t INNER JOIN
Scores s ON t.TitlesID = s.TitlesID
WHERE s.VisibleForWeb = -1

Another way is to use WHERE EXISTS:

SELECT Titles FROM Titles t
WHERE EXISTS (SELECT * FROM Scores s
WHERE s.TitlesID = t.TitlesID AND VisibleForWeb = -1)

HTH,
Bob Barrows


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Guy Verville
9/29/2004 5:48:42 PM
Thank you very much. Yes, it was Access.

Guy

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> a écrit dans le message de
news: eSNEqWlpEHA.3424@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button