Destramic Posted November 16, 2011 Share Posted November 16, 2011 hey guys im trying to get this query working but im getting an error if anyone could tell me whats going wrong please....thank you SELECT CONCAT("[", GROUP_CONCAT( CONCAT("{platform_abbreviation:'", gp.platform_abbreviation,"'"), CONCAT(",game_name:'", g.game_name), CONCAT(",game_abbreviation:'", g.game_abbreviation),"'}") ) ,"]") AS json FROM game_platform_mappings gpm LEFT JOIN game_platforms gp ON gp.game_platform_id = gpm.game_platform_id LEFT JOIN games g ON g.game_id = gpm.game_id error im getting #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 ') AS json FROM game_platform_mappings gpm LEFT JOIN game_platforms gp ON gp.gam' at line 8 Link to comment https://forums.phpfreaks.com/topic/251279-mysql-to-json/ Share on other sites More sharing options...
trq Posted November 17, 2011 Share Posted November 17, 2011 This would be much easier to do if you simply get the data out as normal then use json_encode. this way you'll also be able to reuse your queries. Link to comment https://forums.phpfreaks.com/topic/251279-mysql-to-json/#findComment-1288825 Share on other sites More sharing options...
fenway Posted November 18, 2011 Share Posted November 18, 2011 Or this. Link to comment https://forums.phpfreaks.com/topic/251279-mysql-to-json/#findComment-1289176 Share on other sites More sharing options...
Destramic Posted November 20, 2011 Author Share Posted November 20, 2011 thanks guys Link to comment https://forums.phpfreaks.com/topic/251279-mysql-to-json/#findComment-1289789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.