Recordsetclown
Technical User
Hi,
The primary key for this table is an auto-incremented field called listingsdbelements_id.
I want to concatenate (streetnumber,streetdirection,streetname,streetsuffix)from the following query into an address field. I was looking at CONCAT_WS(streetnumber,streetdirection,streetname,streetsuffix) and wondering how to incorporate that, but I need to do that without adding a new address line to the table if address already exists for this listingsdb_id. The query would be run after every import of data, so the db would contain both existing and new records each time the query is run.
SELECT r1.listingsdbelements_field_value as streetnumber
, r2.listingsdbelements_field_value as streetdirection
, r3.listingsdbelements_field_value as streetname
, r4.listingsdbelements_field_value as streetsuffix
, r5.listingsdbelements_field_value as showaddress
FROM default_en_listingsdbelements AS r1
LEFT OUTER
JOIN default_en_listingsdbelements AS r2
ON r2.listingsdb_id = r1.listingsdb_id
AND r2.listingsdbelements_field_name = 'streetdirection'
LEFT OUTER
JOIN default_en_listingsdbelements AS r3
ON r3.listingsdb_id = r1.listingsdb_id
AND r3.listingsdbelements_field_name = 'streetname'
LEFT OUTER
JOIN default_en_listingsdbelements AS r4
ON r4.listingsdb_id = r1.listingsdb_id
AND r4.listingsdbelements_field_name = 'streetsuffix'
LEFT OUTER
JOIN default_en_listingsdbelements AS r5
ON r5.listingsdb_id = r1.listingsdb_id
AND (r5.listingsdbelements_field_name = 'showaddress'
AND r5.listingsdbelements_field_value = '1')
WHERE r1.listingsdbelements_field_name = 'streetnumber'
Thanks for any help.
The primary key for this table is an auto-incremented field called listingsdbelements_id.
I want to concatenate (streetnumber,streetdirection,streetname,streetsuffix)from the following query into an address field. I was looking at CONCAT_WS(streetnumber,streetdirection,streetname,streetsuffix) and wondering how to incorporate that, but I need to do that without adding a new address line to the table if address already exists for this listingsdb_id. The query would be run after every import of data, so the db would contain both existing and new records each time the query is run.
SELECT r1.listingsdbelements_field_value as streetnumber
, r2.listingsdbelements_field_value as streetdirection
, r3.listingsdbelements_field_value as streetname
, r4.listingsdbelements_field_value as streetsuffix
, r5.listingsdbelements_field_value as showaddress
FROM default_en_listingsdbelements AS r1
LEFT OUTER
JOIN default_en_listingsdbelements AS r2
ON r2.listingsdb_id = r1.listingsdb_id
AND r2.listingsdbelements_field_name = 'streetdirection'
LEFT OUTER
JOIN default_en_listingsdbelements AS r3
ON r3.listingsdb_id = r1.listingsdb_id
AND r3.listingsdbelements_field_name = 'streetname'
LEFT OUTER
JOIN default_en_listingsdbelements AS r4
ON r4.listingsdb_id = r1.listingsdb_id
AND r4.listingsdbelements_field_name = 'streetsuffix'
LEFT OUTER
JOIN default_en_listingsdbelements AS r5
ON r5.listingsdb_id = r1.listingsdb_id
AND (r5.listingsdbelements_field_name = 'showaddress'
AND r5.listingsdbelements_field_value = '1')
WHERE r1.listingsdbelements_field_name = 'streetnumber'
Thanks for any help.