Skip to main content
Participating Frequently
May 12, 2020
Question

weird sql issue passing row from one sql query to another

  • May 12, 2020
  • 1 reply
  • 284 views

Hi all,

I have a weird issue, which I don't think happened the last time I did this on an old machine a few years ago.

 

I am trying to load unique landlords into a table and within that table results of all of their real estate properties

But what is happening is that it will only look at the first record.

This is the SQL for loading the landlord

mysql_select_db($database_db, $db);
$query_loadproperties = sprintf("SELECT Distinct *
								FROM landlord
								LEFT JOIN property ON property.landlord_id = landlord.landlord_id 
								GROUP BY landlord.landlord_id
								ORDER BY landlord.landlord_id ASC", GetSQLValueString($colname_loadproperties, "text"));

And this is the property loading

$query_loadtenant = sprintf("SELECT *
							FROM property
								LEFT JOIN landlord ON property.landlord_id = landlord.landlord_id 
								WHERE landlord.landlord_id = '".$row_loadproperties['landlord_id']."'
								ORDER BY landlord.landlord_id ASC", GetSQLValueString($colname_loadtenant, "int"));

I've tried out a few things but the nearest I can get is to load one property to each landlord.

 

Any help or suggestions would be appricated

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    May 17, 2020

    I've tried several steps to getting this right but not sure if it's a problem with the loop or the sql statement

     

    An edit to the above, it's the repeat region that does not seem to work for other landlords.

    I can load the list of landlords, then the first landlords properties are shown but the subsequent records do not load their properties