Show all from left table who match right table?

Banaticus

Registered User.
Local time
Today, 09:19
Joined
Jan 23, 2006
Messages
153
The part that I'm a little lost on is the WHERE part:

Table1
-----
UniquePersonNumber
blah
yadda

GruntSounds
-----
ooga
booga
blargh

HowSpeak (1 to many relationship with Table1)
-----
UniqueNumber (lookup to UniquePersonNumber field in Table1)
Sounds (lookup to GruntSounds table)

The part that I'm a little lost on is the WHERE part -- the "matching" portion of the FROM was shortened for brevity:
SELECT blah, yadda
FROM Table1 LEFT JOIN HowSpeak ON "matching UniquePersonNumber"
WHERE
"a person makes both an ooga sound and a booga sound but doesn't make a blargh sound"

I hope that I gave enough information from this fictional project to make it clear how I'm attempting to structure the WHERE in the statement.
 
SELECT UniquepersonNumber, Yadda
FROM Table1 T1
LEFT JOIN HowSpeak HS on HS.UniqueNumber = T1.UniquepersonNumber
LEFT JOIN GruntSounds GS ON GS.PK = HS.FK AND GS.Sounds in ("OOGA","BOOGA")
 
I'm sorry, I'm not understanding that there.
"Table1 T1" doesn't need to be "Table1 as T1"?
Where does the PK and FK come from in
LEFT JOIN GruntSounds GS ON GS.PK = HS.FK AND GS.Sounds in ("OOGA","BOOGA")

Perhaps this will make the setup clearer:

People
-----
UniquePersonNumber
Name
Address

Products
-----
TV
VCR
Stereo

Purchases (1 to many relationship with People table)
-----
UniqueNumber (lookup to UniquePersonNumber field in People table)
Product (lookup to Products table)
Date (of purchase)

How about, say, people who've ever purchased a TV and ever purchased a VCR, but who've never purchased a Stereo -- again, the table was just made up off the top of my head.
 
Last edited:
Same thing basically. What I was trying to show was the relationship between GruntSounds and HowSpeak with the PK and FK (Primary key/Foreign Key). You don't have a relatenship between them which of course you would need to be able to check. Basically FK was Sounds (I missed that the first read) from the Howspeak table, and you didn't supply a matching field from the GruntSounds table.
 

Users who are viewing this thread

Back
Top Bottom