×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Jorge Luis Romero Castañeda
Added: Jul 16, 2014 8:02 PM
Views: 14
Tags: no tags
Obtener string en formato JSON a partir de una consulta SQL
  1. SELECT
  2.         CONCAT("[",
  3.                                 GROUP_CONCAT(
  4.                                                 "{coduser:'",u.cod_user,"'",
  5.                                                 ",name:'",REPLACE(u.`name`,"'",''),"'",
  6.                                                 ",lastname:'",REPLACE(u.last_name,"'",''),"'",
  7.                                                 ",status:'",uht.`status`,"'}"
  8.                                 )
  9.          ,"]") 'jugadores'
  10. FROM
  11.         user_has_team AS uht
  12. LEFT JOIN users AS u ON uht.cod_user = u.cod_user
  13. WHERE
  14.         uht.cod_team = '82';