Hello Pesebe-san,

how about this?


SELECT
 t1.name AS cat,
 GROUP_CONCAT(t2.name) AS subcat
FROM table AS t1
LEFT JOIN table AS t2 ON t1.id = t2.parentid
WHERE t1.parentid = 0 GROUP BY cat;

+-------+-------------------+
| cat   | subcat            |
+-------+-------------------+
| cat A | subcat A,subcat A |
| cat B | subcat B          |
+-------+-------------------+
2 rows in set (0.00 sec)


regards,


ts. tanaka//

2012/5/28 HaidarPesebe <haidarpes...@gmail.com>:
> Thanks for the information;
>
> I tried to call the database with something like this;
>
> select id,name from TABLE WHERE parentid='0'
>
> and a second call to the same table as this;
>
> select id,name from TABLE WHERE parentid='$id' (this $id is the result of
> calling the first call TABLE)
>
> and successfully.
> or are there other examples that simple?
>
> Thanks
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature
> database 7173 (20120527) __________
>
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql
>

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to