Highlighted

weird sql issue passing row from one sql query to another

Community Beginner ,
May 12, 2020

Copy link to clipboard

Copied

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

Views

166

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

weird sql issue passing row from one sql query to another

Community Beginner ,
May 12, 2020

Copy link to clipboard

Copied

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

Views

167

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
May 17, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
Learn Resources
Add a group