All pastes #100047 Raw Edit

Phazorx

public sql v1 · immutable
#100047 ·published 2006-07-25 20:46 UTC
rendered paste body
CREATE TABLE `pet` (  `DbId` int(11) NOT NULL auto_increment,  `name` varchar(100) collate latin1_bin NOT NULL default '',  `registration_DbId` int(11) NOT NULL default '0',  `health` float unsigned NOT NULL default '0',  `happiness` float unsigned NOT NULL default '0',  `hunger` tinyint(4) unsigned NOT NULL default '0',  `illness` tinyint(4) NOT NULL default '0',  `points` int(11) NOT NULL default '0',  `isCurrent` tinyint(4) NOT NULL default '0',  `user_DbId` int(11) NOT NULL default '0',  `petClass_DbId` int(11) default NULL,  `item_DbId` int(11) NOT NULL default '0',  `camp` tinyint(4) NOT NULL default '0',  `timer` int(11) NOT NULL default '0',  `gender` tinyint(4) NOT NULL default '1',  `room_DbId` int(11) default NULL,  `location_X` smallint(4) NOT NULL default '1',  `location_Y` smallint(4) NOT NULL default '1',  `rotation` tinyint(4) NOT NULL default '1',  `webkinz_size` tinyint(4) NOT NULL default '1',  `adoptionDate` date NOT NULL,  PRIMARY KEY  (`DbId`),  KEY `petClass_DbId` (`petClass_DbId`),  KEY `user_DbId` (`user_DbId`),  KEY `item_DbId` (`item_DbId`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=112182;SELECT p2.DbId, p2.happiness, p2.user_DbId, MAX( p1.timer ) AS t, count( p1.user_DbId )FROM `pet` AS p1INNER JOIN pet AS p2 ON ( p1.user_DbId = p2.user_DbId )GROUP BY p1.user_DbIdHAVING t <1153713600mysql> SELECT p2.DbId, p2.happiness, p2.user_DbId, count( p1.user_DbId )    -> FROM `pet` AS p1    -> JOIN pet AS p2 ON ( p1.user_DbId = p2.user_DbId )    -> WHERE p2.user_DbId >140    -> GROUP BY p1.user_DbId    -> ORDER BY user_DbId    -> LIMIT 0 , 30;+------+-----------+-----------+-----------------------+| DbId | happiness | user_DbId | count( p1.user_DbId ) |+------+-----------+-----------+-----------------------+|  473 |         0 |       141 |                     1 ||  482 |         0 |       142 |                     4 ||  493 |         0 |       143 |                     1 ||  494 |         0 |       144 |                     1 ||  495 |        80 |       145 |                     9 ||  496 |         0 |       146 |                   729 ||  497 |        50 |       147 |                   225 ||  498 |         0 |       148 |                     1 ||  500 |         0 |       149 |                     1 ||  501 |         0 |       150 |                     4 || 1093 |         0 |       151 |                     1 ||  504 |         0 |       153 |                     1 ||  505 |         0 |       154 |                     1 ||  506 |         0 |       155 |                     1 ||  508 |         0 |       156 |                     1 ||  513 |         0 |       157 |                     9 ||  516 |         0 |       158 |                     1 ||  517 |         0 |       159 |                     1 ||  518 |         0 |       161 |                     4 ||  522 |         0 |       163 |                    49 ||  524 |         0 |       164 |                     1 ||  525 |         0 |       165 |                    25 ||  532 |         0 |       167 |                    25 ||  535 |         0 |       168 |                     1 ||  536 |         0 |       169 |                    64 ||  540 |         0 |       170 |                     9 ||  541 |         0 |       171 |                    81 ||  542 |         0 |       172 |                     1 ||  548 |         0 |       174 |                     9 ||  551 |         0 |       175 |                    36 |+------+-----------+-----------+-----------------------+