The next example is my database.
tb_port id port 1 80 2 22 3 53 4 3128 5 443
tb_dest id dest 1 network 2 local
tb_rule id id_port id_dest 1 1 1 2 2 1 3 3 1 4 4 1 5 5 1
Select:
select dest,group_concat(port) from tb_port a, tb_dest b, tb_rule c where a.id=c.id_port and b.id=c.id_dest group by dest
Result:
network 80,22,53,3128,443
but is not the result I'm looking for, the result would be this.
Select ex: select dest,group_concat(port limit 2) from tb_port a, tb_dest b, tb_rule c where a.id=c.id_port and b.id=c.id_dest group by dest
result I would like
network 80,22 network 53,3128 network 443
how to achieve this result only with SQL?
Sqlfiddle: http://sqlfiddle.com/#!2/d11807