TABLE_1
ID
100
101
TABLE_2
ID Name
100 Sample_1
101 Sample_2
TABLE_3
ID Stock
101 5
My query looks like this:
Code: Select all
$updates = "select p.ID, pd.Name, ps.Stock from " . TABLE_1 . " p, " . TABLE_2 . " pd, " . TABLE_3 . " ps where p.ID = pd.ID and p.ID = ps.ID group by p.ID";ID Name Stock
101 Sample_2 5
The problem I run into is that I want it to show ID 100 as well, but because ID 100 isn't in TABLE_3 it skips it. I would like the resulting data to look like this:
ID Name Stock
100 Sample_1
101 Sample_2 5
If ID 100 is not in table three, I would like to still display the rowdata, but have a blank value for the Stock (I am using this blank value in an If statement based on whether or not there is a stock value).
Can someone explain to me the proper syntax in the query to get this accompished? I've searched and searched and am not sure how to do this. Thanks in advance!!
(Let me know if this is confusing or you'd like more info, please, I need to get this solved)