[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Wed Jan 21 10:40:10 2004 -->
- <!--x-from-r13: qbpk ng vb.pbz (Rlyna @beguehc) -->
- <!--x-message-id: Pine.LNX.4.44.0401210932180.31005-[email protected] -->
- <!--x-reference: 39DB03CC-4C25-11D8-B25B-[email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] any SQL gurus? -->
- <li><em>date</em>: Wed Jan 21 10:40:10 2004</li>
- <li><em>from</em>: docx at io.com (Dylan Northrup)</li>
- <li><em>in-reply-to</em>: <<a href="msg00838.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] any SQL gurus?</li>
:=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
:=later. *8)
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 <*> <a rel="nofollow" href="http://www.io.com/~docx/">http://www.io.com/~docx/</a>
"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'
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00838" href="msg00838.html">[ale] any SQL gurus?</a></strong>
<ul><li><em>From:</em> phasefx at magusaptus.com (Jason Etheridge)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00843.html">[ale] Super-Villians prefer Linux...</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00845.html">[ale] USB->IDE problems</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00847.html">[ale] any SQL gurus?</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00846.html">[ale] any SQL gurus?</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00844"><strong>Date</strong></a></li>
<li><a href="threads.html#00844"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>