MySQL query with "List Options"
2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 23, 2008 (RSS)
By aev - October 23, 2008
Hi!
Is it possible to have a MySQL query for creating a drop-down list for all titles in multiple sections?
This would be similar to the current List Option "Get options from database (advanced)", but with multiple sections.
I tried this code:
But it produced a SQL error, maybe we need some "CONCAT" in there??
We want to use this to enable our clients to link to existing pages.
-aev-
Is it possible to have a MySQL query for creating a drop-down list for all titles in multiple sections?
This would be similar to the current List Option "Get options from database (advanced)", but with multiple sections.
I tried this code:
SELECT num, title FROM cmsb_tableName, cmsb_tableName2, cmsb_tableName3
But it produced a SQL error, maybe we need some "CONCAT" in there??
We want to use this to enable our clients to link to existing pages.
-aev-
Re: [aev] MySQL query with "List Options"
By Dave - October 23, 2008
Hi aev,
This is pretty advanced MySQL - but I can try and point you in the right direction.
MySQL has a command called UNION that you can use to join multiple SELECT queries. Basically you enter your query, then enter "UNION" and another query. You can read the docs for it here: http://dev.mysql.com/doc/refman/5.0/en/union.html
And here's some sample code:
SELECT num, fullname FROM cms_accounts
UNION SELECT num, title FROM cms_jobs
UNION SELECT num, title FROM cms_news
Hope that helps!
This is pretty advanced MySQL - but I can try and point you in the right direction.
MySQL has a command called UNION that you can use to join multiple SELECT queries. Basically you enter your query, then enter "UNION" and another query. You can read the docs for it here: http://dev.mysql.com/doc/refman/5.0/en/union.html
And here's some sample code:
SELECT num, fullname FROM cms_accounts
UNION SELECT num, title FROM cms_jobs
UNION SELECT num, title FROM cms_news
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com