POPULATE A FIELD IN A DATABASE TABLE FROM FIELDS IN ANOTHER TABLE - Aug 1st, 2010


A way to take 3 fields from one table entered in one Editor and have then populate one field in another Editor. Let’s
say in the first section there are 3 fields: code, product and format.
I enter all my products using that Editor.
I have setup another Editor to enter some specials for some chosen products. When adding new special I would like to be
able to select products - entered in the previous Editor - from a list that is populated from the code, product, format
field from the other table (Editor).

Under list options selected "Get options from MySQL Query (advanced)" and enter this (use your own table prefix and
table name instead of cms_tablename):



SELECT num, CONCAT_WS(" ", code, product, format) FROM cms_tablename

The CONCAT_WS mysql function means "concatenate with string" or "join these fields together with this first value". So
in the above example it would join code, product, and format together with a space and return that as the pull down
"label". I set the pull down "value" as the num field. If you want the joined value for both just use this:



SELECT CONCAT_WS(" ", code, product, format), CONCAT_WS(" ", code, product, format) FROM cms_tablename



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service