Pesebe-san, I'm sorry to i'm not clear what do you want to do. do you mean like this? (exampled by Perl)
#--- use DBI; $cn = DBI->connect("DBI:mysql:test","root",""); $st = $cn->prepare("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;"); $st->execute; while ($rs = $st->fetchrow_hashref) { print $rs->{cat},"<br>\n"; @buff = split(/,/,$rs->{subcat}); foreach $i (@buff) { print " -",$i,"<br>\n"; } } #--- regards, ts. tanaka// 2012/5/30 HaidarPesebe <haidarpes...@gmail.com>: > and also id (either cat or subcat) can be called > > ----- Original Message ----- From: "HaidarPesebe" <haidarpes...@gmail.com> > To: "MySQL Lists" <mysql@lists.mysql.com> > Sent: Wednesday, May 30, 2012 2:31 PM > Subject: Re: category with parentid > > > >> Hello ts. Tanaka, >> >> I've tried your way and succeed. Thank you. >> But I want to ask your help again what if the result will be like this: >> >> A. Cat A >> Â Â Â - Subcat A >> Â Â Â - Subcat A >> 2. CatB >> Â Â Â - Subcat B >> >> possible by using <br> or <div> >> >> which the previous result is >> Cat A - SubcatA, SubcatA >> Cat B - SubcatB >> >> thank you >> >> __________ Information from ESET NOD32 Antivirus, version of virus >> signature database 7179 (20120529) __________ >> >> The message was checked by ESET NOD32 Antivirus. >> >> http://www.eset.com >> >> >> > > > __________ Information from ESET NOD32 Antivirus, version of virus signature > database 7179 (20120529) __________ > > 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