Jump to content

Archived

This topic is now archived and is closed to further replies.

Tandem

mysql / php help

Recommended Posts

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.

Share this post


Link to post
Share on other sites
SELECT username FROM users,monkies WHERE test = 1

I think this would be the correct syntax for doing this... 

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Please use proper JOIN syntax... you'll thank me later.

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.