Query to group results according to parent attribute
Hello and thank you in advance.
I have a table like that:
CREATE TABLE IF NOT EXISTS `Test` (
`ID` INT NOT NULL AUTO_INCREMENT ,
`Parent` VARCHAR(45) NOT NULL ,
`Child` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`ID`) )
ENGINE = InnoDB;
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('1', 'X', 'a');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('2', 'X', 'b');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('3', 'X', 'c');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('4', 'Y', 'a');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('5', 'Y', 'b');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('6', 'Z', 'a');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('7', 'W', 'a');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('8', 'W', 'b');
INSERT INTO `Test` (`ID`,`Parent`,`Child`) VALUES ('9', 'W', 'c');
I would like if exists a way to print (on a html page) something like that:
X
a
b
c
Y
a
b
Z
a
W
a
b
c
Thank you