Tandem Posted August 28, 2006 Share Posted August 28, 2006 I was wondering, is it possible to select records from two different tables in one query?If so can somebody show me a theoretical example? I would like to use this for a php script.Thanks in advance fo any help. Quote Link to comment Share on other sites More sharing options...
radar Posted August 28, 2006 Share Posted August 28, 2006 SELECT username FROM users,monkies WHERE test = 1I think this would be the correct syntax for doing this... Quote Link to comment Share on other sites More sharing options...
Tandem Posted August 28, 2006 Author Share Posted August 28, 2006 Thanks, that was really helpful! Quote Link to comment Share on other sites More sharing options...
radar Posted August 28, 2006 Share Posted August 28, 2006 Now the question is, does it work... lol.. I haven't actually tested that right this second but i did it once and i think thats the way i did it... Quote Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 yes it is possible. doing something as simple as this will work:[color=red]select * from table1,table2[/color]was that the end-all-be-all of your question, or were you trying to do something specific? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 28, 2006 Share Posted August 28, 2006 Please use proper JOIN syntax... you'll thank me later. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 28, 2006 Share Posted August 28, 2006 [quote author=Crayon Violent link=topic=105890.msg423173#msg423173 date=1156743671]yes it is possible. doing something as simple as this will work:[color=red]select * from table1,table2[/color][/quote]@CV,Yes, it will work but inless you specify how the tables should be joined you get every row in table1 joined with every row in table2 (cartesian join) so if you have 100 rows in each table you get 10,000 rows returned Quote Link to comment Share on other sites More sharing options...
.josh Posted August 29, 2006 Share Posted August 29, 2006 yeah i know. my example was more along the lines of uh..cheekiness? sarcasm? it was more of an effort to get him to be more specific :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.