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, 201
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 wa
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 or
which the previous result is
Cat A - SubcatA, SubcatA
Cat B - SubcatB
O, and the algorithm that I described only then works when the graph is
cycle-free. Otherwise it forever runs.
**
Scanned by MailScan AntiVirus and Content Security Software.
Visit http://www.escanav.com for more info on eScan and X-Spa
2012/05/28 12:54 +0700, HaidarPesebe
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)
Others have said, and I agree, you have a graph
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
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 successful
2012/05/25 10:07 -0500, Andrés Tello
You have a typical hierarchical data issue, can be solved with a graph.
Theory review: http://www.algorithmist.com/index.php/Graph_data_structures
Mysql and PHP implementation:
http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-My
On 2012-05-25 8:35 AM, h...@tbbs.net wrote:
2012/05/25 14:57 +0700, HaidarPesebe
id | name | parentid
--
1 | cat A | 0
2 | cat B | 0
3 | subcat A | 1
4 | subcat A | 1
5 | subncat B | 2
-
I want to display the result like this:
1. Cat
You have a typical hierarchical data issue, can be solved with a graph.
Theory review: http://www.algorithmist.com/index.php/Graph_data_structures
Mysql and PHP implementation:
http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-MySQL.html
2012/05/25 14:57 +0700, HaidarPesebe
id | name | parentid
--
1 | cat A | 0
2 | cat B | 0
3 | subcat A | 1
4 | subcat A | 1
5 | subncat B | 2
-
I want to display the result like this:
1. Cat A
- Subcat A
- Subcat A
2. Ca
I have a database for the category
id | name | parentid
--
1 | cat A | 0
2 | cat B | 0
3 | subcat A | 1
4 | subcat A | 1
5 | subncat B | 2
-
I want to display the result like this:
1. Cat A
- Subcat A
- Subcat A
2. CatB
-
12 matches
Mail list logo