Jump to content

mysql: select certain fields from multiple tables in one query?


Anti-Moronic

Recommended Posts

Currently, I use this:

 

select * from table1, table2 where table1.id=table2.id

 

That works fine, but what if I don't want to fetch tons of data from table 2, but just a single field? How do I do that? Also, can I also only select certain fields from the first table?

 

Appreciate any help.

got it. I should really have more confidence in myself.:

 

select table1.*, table2.field1 from table1, table2 where table1.id=table2.id

 

Hope it helps someone else looking for a quick answer.

Archived

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

×
×
  • Create New...

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.