I was trying something with one of the functions that mysql provided - Group_Concat to get some data in an order that would make it easy for me to analyze... I wasn't particularly clear about getting the data in a format that I wanted... Using group_concat do you know of a way of getting the sub children too in a single line? As of now, I am able to get the following:
Parent -> A
Children -> B E F G
Parent -> B
Children-> C D
From a Table:
A | B
A | E
A | F
A | G
B | C
B | D
Where X | Y indicates that X is related to Y somehow.
What I wanted was something like if C and D are children of B, then I want something like:
Parent -> A
Children -> B{C,D} E F G
The statement that I framed was:
SELECT ip2 AS Parent, GROUP_CONCAT(ip1 SEPARATOR ', ') AS Children FROM br GROUP BY ip2;
With great difficulty I was able to write a solution but I realised it isn't doing what I want it to do... Someone please help me...
Help with GROUP_CONCAT & GROUP_BY
Moderator: General Moderators
Help with GROUP_CONCAT & GROUP_BY
Last edited by legend986 on Fri Nov 09, 2007 1:25 am, edited 2 times in total.
Descriptive Subjects
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
In this case I think you'll essentially need two queries.
Your other option is to use Modified Preorder Tree Traversal
Your other option is to use Modified Preorder Tree Traversal