Jump to content

get query info


proctk

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.