Re: [rjbathgate] Display two fields in List select
Hi Rob,
The way the "Get Options from MySQL" works is it uses the first field as the "value" (that gets stored in the database) and the second field as the "label" (that gets displayed to the user).
Often you want to store the record num as the value because you know that will never change. In the case of categories if you used the name as a lookup and the name changes then the record won't be associated. That's why we have the two fields.
There's a list of MySQL string functions here: http://dev.mysql.com/doc/refman/4.1/en/string-functions.html
To join two fields with a space we can use CONCAT_WS(). Try this:
SELECT num, CONCAT_WS(' ',forename,surname) FROM cms_contacts
Have the record number also makes it easier later if you need to load the account record. But if your project doesn't need that feel free to just use CONCAT_WS twice for both values.
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com