Jump to content

Query returns empty row


EchoFool

Recommended Posts

Hey,

 

 

I have a query which returns a row with no values in the fields, technically it should not find a row based on my current example data, but it still finds one. I have no idea how to solve this.... please can you help.

 

 

Here is my query:

 

 

<?php
   SELECT *,count(t3.userid) as Total 
   FROM user_settings t1
   INNER JOIN users t2
   ON  t1.userid=t2.UserID
   LEFT JOIN users_pictures t3
   ON t1.userid=t3.userID
   WHERE TIMESTAMPDIFF(DAY,LastAction,NOW()) < 34
   AND NOT EXISTS
             (
              SELECT id FROM users_blocked
              WHERE (user1='$myid' AND user2=t2.UserID)
              OR (user1=t2.UserID AND user2='$myid')
             )
   LIMIT 50
?>

 

I am wondering if my count() is causing it ? IF so how can i solve it ?

 

Thanks :)

Link to comment
Share on other sites

The left join is to see if the user has images uploaded to their profile.

 

Because the query is only to load users who have images of 1 or more. But some users can decide to load users without images, so i used a left join and just echo'd how many images the user has uploaded to their profile adjacent to their name like:

 

User 1 : 0 images.

User 2:  5 images.

 

etc.

 

But if it finds no users it comes up with a empty row showing 0 images. I tried to merge it into one query for efficiency which i do as much as possible.

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.