[quoted text, click to view] Guy Verville wrote:
> 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
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.