proctk Posted March 6, 2008 Share Posted March 6, 2008 Hi I have a query that is returning the correct information however its adding in blank rows, I reviewed my tables to see if there were records that would cause this. I'm lookig to have somthing returned to help me determine why there are extra recoreds returned. here is my code $sqlbuddy = " SELECT buddylink.owner_id, buddylink.buddy_id, users.first_name, users.last_name, users.DOB FROM buddylink LEFT JOIN users ON buddylink.buddy_id = users.user_id ".$qryUserDate ." WHERE buddylink.owner_id = $id". $exString; echo $sqlbuddy; $qrybuddy = mysql_query($sqlbuddy)or die("SQL Error: $sqlbuddy<br>" . mysql_error()); $sqlBuddy returns SELECT buddylink.owner_id, buddylink.buddy_id, users.first_name, users.last_name, users.DOB FROM buddylink LEFT JOIN users ON buddylink.buddy_id = users.user_id AND (month(users.DOB) = 03) WHERE buddylink.owner_id = 63 AND buddylink.buddy_id <>4 AND buddylink.buddy_id <>5 AND buddylink.buddy_id <>7 AND buddylink.buddy_id <>13 AND buddylink.buddy_id <>26 AND buddylink.buddy_id <>178 When I call the result <?php while($rbuddy = mysql_fetch_assoc($qrybuddy)) : ?> <?php echo 'Yes'.$rbuddy['DOB']; ?><br/> <?php endwhile; ?> I get Yes Yes Yes1953-03-19 Yes1990-03-05 Yes Yes1966-03-15 The Yes with no date next to them should not be there any help is great Link to comment https://forums.phpfreaks.com/topic/94617-get-query-info/ Share on other sites More sharing options...
proctk Posted March 6, 2008 Author Share Posted March 6, 2008 I figured out this much. Its returning the entries that I want but it including the entrys that the month is not found also, Its giving me the blank record. I found a fix by using an if statement however I never had a query do this before any thoughts Link to comment https://forums.phpfreaks.com/topic/94617-get-query-info/#findComment-484501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.