mysql - Query not outputting all relevant results from database -


i trying output relevant values database using code below. reason, information not output should be, , don't know why.

i'm guessing there wrong query?

$result = mysql_query(         "select           tbl_status.id statid,          tbl_status.from_user statfrom,          tbl_status.status statstatus,          tbl_status.deleted statdel,          tbl_status.date statdate,          tbl_users.id usrid,          tbl_users.name usrname,          tbl_photos.profile photosprofile,         tbl_photos.photo_link photolink,         tbl_photos.default_photo photodefault           tbl_status          inner join tbl_users on tbl_status.from_user = tbl_users.id          inner join tbl_photos on tbl_photos.profile = tbl_users.id          tbl_status.deleted = '0' , tbl_photos.default_photo = '1'         order tbl_status.date desc;          "); 

based on query, here 4 possible reasons you're not seeing statuses:

  1. you're using inner join tbl_photos, user doesn't have photo excluded.
  2. you're using inner join tbl_users, status doesn't relate @ least 1 user (and user must have photo - see #1) excluded.
  3. you're filtering on tbl_photos.default_photo = '1', photo tbl_photos.default_photo <> '1' excluded. because of inner joins, exclude associated user , possibly exclude associated status.
  4. you're filtering on tbl_status.deleted = '0', status delete <> '0' excluded. obvious, worth mentioning.

try this: change inner join tbl_users left join tbl_users, , change inner join tbl_photos left join tbl_photos. if doesn't give results expect, please post sample data , expected results.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -