Jump to content

Archived

This topic is now archived and is closed to further replies.

ricbax

ERROR At GROUP_CONCAT

Recommended Posts

[!--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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.