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 |
I have been working with a query but need to add a few more
conditions. I was a to do a query that contains a few more selects but
want to know if there is a more efficient way to get results I need:
This query is to find NEW or FORMER CLIENT within a moving window
(Date Range) of time.
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, and some
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
2012/05/28 08:03 -0700, Don Wieland
Any assistance would be appreciated. Thanks!
Maybe something like this:
SELECT usie.client_id, first_name, last_name, COUNT(anie.client_id)
FROM
(SELECT client_id, first_name, last_name, time_start
FROM tl_appt
JOIN tl_rooms USING(room_id)
JOIN tl_clients