ricbax Posted November 2, 2005 Share Posted November 2, 2005 [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]mysql> [span style=\'color:blue;font-weight:bold\']select[/span] * from repairs; +----+---------------------------------+------------------------------------------+ | id | cat_1 | cat_2 | +----+---------------------------------+------------------------------------------+ | 1 | Renovation, Regular Maintenance | Air Conditioning Contractors and Systems | | 2 | Repair | Air Conditioning Equipment-Repair | | 3 | Regular Maintenance | Air Conditioning Systems-Cleaning | +----+---------------------------------+------------------------------------------+ 3 rows in set (0.00 sec) mysql> [span style=\'color:blue;font-weight:bold\']INSERT[/span] INTO dynamic1 (cat_1, cat_2) VALUES (([span style=\'color:blue;font-weight:bold\']SELECT[/span] GROUP_CONCAT(cat_1) FROM repairs WHERE cat_2 IN ('Air Conditioning Contractors [span style=\'color:blue\']and Systems'[/span], 'Air Conditioning Equipment[span style=\'color:orange\']-Repair'[/span], 'Air Conditioning Systems[span style=\'color:orange\']-Cleaning'[/span])), 'Air Conditioning Contractors [span style=\'color:blue\']and Systems, Air Conditioning Equipment-Repair, Air Conditioning Systems-Cleaning'[/span]); Query OK, 1 row affected (0.00 sec) mysql> [span style=\'color:blue;font-weight:bold\']select[/span] * from dynamic1; +----+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | id | cat_1 | cat_2 | +----+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | 4 | Renovation, Regular Maintenance,Repair,Regular Maintenance | Air Conditioning Contractors and Systems, Air Conditioning Equipment-Repair, Air Conditioning Systems-Cleaning | +----+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) [!--sql2--][/div][!--sql3--] #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT GROUP_CONCAT(cat_1) FROM repairs WHERE cat_2 IN ('Air Co I keep getting this error. I did get this query to work once but I forget what I did to get it to work ... please help. Quote Link to comment https://forums.phpfreaks.com/topic/2785-error-at-group_concat/ Share on other sites More sharing options...
ricbax Posted November 2, 2005 Author Share Posted November 2, 2005 Is there an alternative to this function for MySQL 4.0 I realized that the GROUP_CONCAT () only works on MySQL 4.1 and above. Quote Link to comment https://forums.phpfreaks.com/topic/2785-error-at-group_concat/#findComment-9320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.