OS_Tim Posted September 25, 2006 Posted September 25, 2006 I never know exactly where to post questions like this, so mod.'s please move if you want. I have a PHP query question that I'll break down in to a very simple example (hopefully). I have a query that is looking at three tables, let's say those three tables have minimal data: 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: $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"; Displaying the results in a datarow where I want to show the ID, the Name and the Stock would show the following: 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)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.