使用"group By"而不使用group_cancat函数时查询以获取隐藏数据 [英] query to get concatinated data when using 'group By' without using group_cancat function

查看:220
本文介绍了使用"group By"而不使用group_cancat函数时查询以获取隐藏数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...
我有一个这样的聊天表

hi all...
i have a chat table like this

id    msg      firstname    lastname
1      hi       rams         var
2      hello    rams         var
3      hi..     var          rams
4      h r u?   rams         var
5      m fin    var          rams
6      h abt u? var          rams
7      gud      rams         vat


在这里我需要得到类似
的结果


here i need to get result like

rams:hi hello
var: hi
rams:h r u?
var m fin h abt u?
rams:gud


为此,我写了类似的查询:


for this i have written query like:

select concat(firstname,':',msg,'<br />) as msg from chattbl group by firstname order by id asc


结果:


it results:

rams:hi 
var: hi


但是在这里,如果我使用group_cancat函数,则需要根据上表的名字来概括所有数据.在这里,它将结果设置为一定的限制,但是在此,用户输入可能没有限制.
谁能帮帮我....
在此先感谢....


but here i need to concatinate all the data according to firstname of above table if i use group_cancat function here it limits the results set up to some limit but here user input may not have limitation .
can any one please help me....
thanks in advance....

推荐答案

我由于使用mysql而失败,因此我只是为服务器端编写了代码
i was failure from taking mysql so that i simply written code for server side


这篇关于使用"group By"而不使用group_cancat函数时查询以获取隐藏数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆