[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] any SQL gurus?
- Subject: [ale] any SQL gurus?
- From: docx at io.com (Dylan Northrup)
- Date: Wed Jan 21 10:40:10 2004
- In-reply-to: <[email protected]>
A long time ago, (21.01.04), in a galaxy far, far away, Jason Etheridge wrote:
:=Hi guys, this has been driving me nuts and maybe you would enjoy
:=figuring it out. :)
:=I have two tables: TITLE and COPY. There is a one-to-many relationship
:=between the two; for any given title, there could be many copies.
:=Copies have owners, but titles don't belong to anyone.
:= table TITLE:
:= field title_key PRIMARY KEY
:= field name CHAR
:= table COPY:
:= field copy_key PRIMARY KEY
:= field title_key FOREIGN KEY
:= field owner CHAR
:=However, owners would like a list of what titles they happen to have
:=copies for. I can do this through brute-force with a programming
:=language, but is there a single SQL query I could use? Specifically,
:=MySQL (I don't have sub-selects)?
:=I'm sure this is simple and obvious and I'll feel like more of an idiot
I'm not much of a SQL guru, but wouldn't this work:
select t.name from t TITLE, c COPY where c.owner = "whoever" and
c.title_key = f.title_key;
Dylan Northrup <*> docx at io.com <*> http://www.io.com/~docx/
"Harder to work, harder to strive, hard to be glad to be alive, but it's
really worth it if you give it a try." -- Cowboy Mouth, 'Easy'