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
https://forums.phpfreaks.com/topic/248867-query-returns-empty-row/
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.

Archived

This topic is now archived and is closed to further replies.

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