seleccionar 1 columna puede coincidir con muchas columnas

I have the 1 table (tblcsv) in database that have data as below:

fieldA  fiel B
aaaa    1

aaaa    2

aaaa    4

a       1

aaaa    2

a       3

bbbb    4

b       3

bbbb    4

b       3

What I need to display:

aaaa        1
            2
            4
            2
a           1
            3
bbbb        4
            4
b           3
            3

I really do not know how to write mysql for query it from database to display what I need.Anyone help me please, Thanks.

preguntado el 28 de agosto de 12 a las 10:08

you can get the data by using order by on "fieldA " and then use PHP to format your data -

.. oreder by fieldA, fieldB - you will have to do the rest with php -

3 Respuestas

  SELECT fieldA, fieldB 
  FROM tblcsv 
  order by feildA

Respondido 28 ago 12, 10:08

select fieldA , fiel B from table 
order by fieldA ;

Respondido 28 ago 12, 10:08

Thanks for your answer,but if I do like this it will loop all record of fieldA that has the same name like aaaa aaaa for many time.I want it display one time. - user1629258

Creo que necesitas GROUP_CONCAT

SELECT fieldA, GROUP_CONCAT(fieldB) 
FROM    tblcsv

Respondido 28 ago 12, 10:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.