2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 4, 2011   (RSS)

Re: [Deborah] create list field from merged field in two other tables

By Jason - July 4, 2011

Hi Deborah,

You can use mysql UNION SELECT to accomplish this. In this example, we use listing_number as both the value and the label for the checkboxes. This method does assume that listing_number is a unique value across both tables.

SELECT merged.listNumValue, merged.listNumLabel
FROM (SELECT listing_number AS listNumValue, listing_number AS listNumLabel
FROM `<?php echo $TABLE_PREFIX;?>table_1`
UNION SELECT listing_number, listing_number
FROM `<?php echo $TABLE_PREFIX;?>table_2`) AS merged
GROUP BY merged.listNumValue


Hope this helps get you started
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/