Jump to content

[SOLVED] Selecting from multiple tables trouble


Jessica

Recommended Posts

Hey guys. I am trying to get info out of a database. There is a table of "foods" and a table of "brands". Some foods have a brandID, and some don't (0). I want to select all of the foods and their brand. The problem is when I do this:

SELECT food.*, brands.* WHERE food.brandID = brand.brandID

I don't get the food items that don't have a brand.

 

The obvious solutions is to do 2 sql statements, selecting the foods and then the brands, then using PHP to put them together.

 

But, is there a way to do it in one statement?

 

Thanks!

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.