From: Tsubasa Tanaka Date: May 30 2012 2:30pm Subject: Re: category with parentid List-Archive: http://lists.mysql.com/mysql/227554 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 =3D DBI->connect("DBI:mysql:test","root",""); $st =3D $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 =3D t2.parentid WHERE t1.parentid =3D 0 GROUP BY cat;"); $st->execute; while ($rs =3D $st->fetchrow_hashref) { print $rs->{cat},"
\n"; @buff =3D split(/,/,$rs->{subcat}); foreach $i (@buff) { print " -",$i,"
\n"; } } #--- regards, ts. tanaka// 2012/5/30 HaidarPesebe : > and also id (either cat or subcat) can be called > > ----- Original Message ----- From: "HaidarPesebe" > To: "MySQL Lists" > 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 >> =A0 =A0 =A0- Subcat A >> =A0 =A0 =A0- Subcat A >> 2. CatB >> =A0 =A0 =A0- Subcat B >> >> possible by using
or
>> >> 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 signat= ure > 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: =A0 =A0http://lists.mysql.com/mysql >