KiPiPo.com blog gadget design wallpaper web programming review

7Nov/100

the various uses of “group by” in mysql

I will explain some useful tips  using "group by" query in mysql.

First create new table for testing in your database ...

CREATE TABLE `movie` (
`id` tinyint(4) NOT NULL auto_increment,
`title` varchar(100) default NULL,
`genre` varchar(100) default NULL,
`price` double(10,2) default NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM;

INSERT INTO `movie` (`id`, `title`, `genre`, `price`) VALUES (1, 'Spiderman', 'action', 5.00);
INSERT INTO `movie` (`id`, `title`, `genre`, `price`) VALUES (2, 'Hulk', 'action', 4.00);
INSERT INTO `movie` (`id`, `title`, `genre`, `price`) VALUES (3, 'Romance in the rain', 'romance', 4.00);
INSERT INTO `movie` (`id`, `title`, `genre`, `price`) VALUES (4, 'Hello World', 'comedy', 10.00);
INSERT INTO `movie` (`id`, `title`, `genre`, `price`) VALUES (5, 'Bang Bang', 'comedy', 6.00);