Getting the value from another table in my database

amount

I’m trying to get the 123 from my image_text and insert into my property table inside the amount

I don’t know if I’m using a correct JOIN to get the value

$sql="SELECT property.property_id,property.property_type,property.location,property.size,property.imageType,property.imageData,property.status,property.tax_payer_id
						FROM property
						LEFT JOIN qr_code
						ON property.amount = qr_code.image_text
						   " ;

I don’t see field in qr_code indicating the a record belongs to property_id. Am I missing something?
Generally this question seems off as if image_txt is supposed also be the amount value they should have been saved at the same time or one table updated when the other is saved… Something like that, rather than a query to populate a field from another field.

BUT assuming you really need to pass these values to populate the table AND the qr_code table HAS a property_id field so you can match up these tables, you could do a query like this.

$sqlupdate = "UPDATE property p
		LEFT JOIN qr_code q ON q.property_id = p.property_id
			SET p.amount = q.image_text";
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.