[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



To answer the question of 'consolidate into one SQL statement"
1) use subqueries:
select * from users where ID in ( select User_ID from ALARMS where ID = 1 );

or 2) define a view.



-----Original Message-----
From: Christopher Fowler [<a  rel="nofollow" href="mailto:cfowler";>mailto:cfowler</a> at outpostsentinel.com]
Sent: Thursday, April 01, 2004 9:04 AM
To: ale at ale.org
Subject: [ale] MySQL Question


I do the following select statements to get a username out of a
database.

SELECT USER_ID from ALARMS where ID = 1;
SELECT * from USERS where ID = '&lt;USER_ID from above&gt;';

I want to speed this up.  Can I consolidate into one SQL statement?



_______________________________________________
Ale mailing list
Ale at ale.org
<a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00019" href="msg00019.html">[ale] MySQL Question</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00021" href="msg00021.html">[ale] MySQL Question</a></strong>
<ul><li><em>From:</em> james at sumners.ath.cx (James Sumners)</li></ul></li>
<li><strong><a name="00026" href="msg00026.html">[ale] MySQL Question</a></strong>
<ul><li><em>From:</em> kafka at antichri.st (George Carless)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00017.html">[ale] MySQL Question</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00019.html">[ale] MySQL Question</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00017.html">[ale] MySQL Question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00019.html">[ale] MySQL Question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00018"><strong>Date</strong></a></li>
<li><a href="threads.html#00018"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>