The following query doesn't do the GROUP BY: ============================================ mysql> mysql> SELECT master_number, MIN( group_start_year ) AS start_year, MAX( group_end_year ) AS end_year, 0 AS toc_seq -> FROM `master_numbers` -> INNER JOIN sections ON sections.fk_mno = master_numbers.master_number -> WHERE master_numbers.released =1 -> AND master_numbers.master_number <5 -> AND sections.show_in_toc =1 -> GROUP BY master_number, toc_seq; +---------------+------------+----------+---------+ | master_number | start_year | end_year | toc_seq | +---------------+------------+----------+---------+ | 1 | 1801 | 1801 | 0 | | 1 | 1801 | 1801 | 0 | | 1 | 1801 | 1801 | 0 | | 1 | 1801 | 1801 | 0 | | 1 | 1801 | 1801 | 0 | | 1 | 1801 | 1801 | 0 | | 4 | 1811 | 1811 | 0 | | 4 | 1811 | 1811 | 0 | | 4 | 1811 | 1811 | 0 | | 4 | 1811 | 1811 | 0 | | 4 | 1811 | 1811 | 0 | | 4 | 1811 | 1811 | 0 | +---------------+------------+----------+---------+ 12 rows in set, 1 warning (0.00 sec) The following query (using '0 AS xyz') produces the expected result set: ======================================================================== mysql> mysql> mysql> SELECT master_number, MIN( group_start_year ) AS start_year, MAX( group_end_year ) AS end_year, 0 AS xyz -> FROM `master_numbers` -> INNER JOIN sections ON sections.fk_mno = master_numbers.master_number -> WHERE master_numbers.released =1 -> AND master_numbers.master_number <5 -> AND sections.show_in_toc =1 -> GROUP BY master_number, xyz; +---------------+------------+----------+-----+ | master_number | start_year | end_year | xyz | +---------------+------------+----------+-----+ | 1 | 1801 | 1801 | 0 | | 4 | 1811 | 1811 | 0 | +---------------+------------+----------+-----+ 2 rows in set (0.00 sec) mysql> Here is a strip-down version of my 2 SQL tables: ================================================ -- -- Table structure for table `master_numbers` -- CREATE TABLE `master_numbers` ( `master_number` smallint(6) unsigned NOT NULL default '0', `batch_code` char(2) NOT NULL default '', `mno_sequence` smallint(6) unsigned NOT NULL default '0', `relevance_start_year` smallint(4) unsigned NOT NULL default '0', `relevance_end_year` smallint(4) unsigned NOT NULL default '0', `group_start_year` smallint(4) unsigned NOT NULL default '0', `group_end_year` smallint(4) unsigned NOT NULL default '0', `geography` varchar(20) NOT NULL default '', `geography_code` varchar(10) NOT NULL default '', `resource_type` varchar(21) NOT NULL default ' ', `resource_code` char(2) NOT NULL default '', `resource_sort` smallint(2) unsigned NOT NULL default '0', `pp_year` varchar(20) NOT NULL default '', `volume` varchar(20) NOT NULL default '', `command_no` varchar(20) NOT NULL default '', `fulltitle` text NOT NULL, `microfiche` varchar(20) NOT NULL default '', `alt_title` text NOT NULL, `alt_title_updated` char(1) NOT NULL default '', `pages` smallint(6) unsigned NOT NULL default '0', `displaylabel` tinytext NOT NULL, `publisher` varchar(100) NOT NULL default '', `date_captured_start` varchar(20) NOT NULL default ' ', `date_captured_end` varchar(20) NOT NULL default ' ', `abstract` text NOT NULL, `scanned_by` char(4) NOT NULL default '', `released` tinyint(1) unsigned NOT NULL default '0', `href` text NOT NULL, `mime_type` varchar(20) NOT NULL default ' ', `last_changed` date NOT NULL default '0000-00-00', `subjects` text NOT NULL, `topics` text NOT NULL, `author` varchar(60) NOT NULL, `has_ocr` tinyint(1) unsigned NOT NULL default '0', `lang` char(3) NOT NULL, PRIMARY KEY (`master_number`), KEY `rescode_year` (`resource_code`,`relevance_start_year`,`relevance_end_year`), KEY `geocode_year` (`geography_code`,`relevance_start_year`,`relevance_end_year`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `master_numbers` -- INSERT INTO `master_numbers` VALUES (1, 'A', 1, 1801, 1801, 1801, 1801, 'Great Britain', 'EWS', 'Census', 'C', 1, '1801', 'VI.813', '140', 'Census of Great Britain, 1801, Abstract, presented to the House of Commons, of the answers and returns made to the Population Act of 41st Geo. III &c.', '1.28-29', 'Population abstract, 1801', 'y', 8, '', '', '0000-00-00', '', '', 'CDDA', 1, '', '', '0000-00-00', '', '', '', 2, 'eng'); INSERT INTO `master_numbers` VALUES (2, 'A', 2, 1801, 1801, 1801, 1801, 'Great Britain', 'EWS', 'Census', 'C', 1, '1801-02', 'VI.1', '9', 'Census of Great Britain, 1801, Abstract of the answers and returns made pursuant to an Act, passed in the forty-first year of His Majesty King George III. intituled "An act for taking an account of the population of Great Britain, and the increase or diminution thereof". Enumeration. Part I. England and Wales. Part II. Scotland', '2.32-37', 'Enumeration abstract, 1801', 'y', 0, '', '', '0000-00-00', '', '', 'CDDA', 0, '', '', '0000-00-00', '', '', '', 0, 'eng'); INSERT INTO `master_numbers` VALUES (3, 'A', 3, 1801, 1801, 1801, 1801, 'Great Britain', 'EWS', 'Census', 'C', 1, '1801-02', 'VII.1', '112', 'Census of Great Britain, 1801, Abstract of the Answers and returns made pursuant to an Act, passed in the forty-first year of His Majesty King George III. intituled "An act for taking an account of the population of Great Britain, and the increase or diminution thereof". Parish-registers', '2.38-42', 'Parish register abstract, 1801', 'y', 0, '', '', '0000-00-00', '', '', 'CDDA', 0, '', '', '0000-00-00', '', '', '', 0, 'eng'); INSERT INTO `master_numbers` VALUES (4, 'A', 4, 1811, 1811, 1811, 1811, 'Great Britain', 'EWS', 'Census', 'C', 1, '1812', 'X.171', '12', 'Census of Great Britain, 1811, Comparative statement of the population of the several counties of Great Britain, in the years 1801 and 1811', '13.80', 'Comparative statement, 1811', 'y', 4, '', '', '0000-00-00', '', '', 'CDDA', 1, '', '', '0000-00-00', '', '', '', 2, 'eng'); -- -------------------------------------------------------- -- -- Table structure for table `sections` -- (There is a one-to-many relationship between -- the previous table and this one) -- CREATE TABLE `sections` ( `fk_mno` smallint(6) unsigned NOT NULL default '0', `st_id` smallint(6) unsigned NOT NULL default '0', `toc_seq` mediumint(7) unsigned NOT NULL default '0', `is_section` tinyint(1) unsigned NOT NULL default '1', `no_toc_section` tinyint(1) unsigned NOT NULL default '0', `childof` smallint(6) unsigned NOT NULL default '0', `nodelevel` tinyint(2) unsigned NOT NULL default '1', `leafnode` tinyint(1) unsigned NOT NULL default '0', `long_name` text NOT NULL, `short_name` text NOT NULL, `toc_label` varchar(60) NOT NULL, `show_in_toc` tinyint(1) unsigned NOT NULL default '1', `subjects` text NOT NULL, `topics` text NOT NULL, `t_scanned_by` char(4) NOT NULL, `t_batch` char(2) NOT NULL, `t_chunk` char(5) NOT NULL, `t_original_fname` varchar(40) NOT NULL, `t_downloadable` tinyint(1) unsigned NOT NULL default '0', `table_type` char(1) NOT NULL default '', `t_download1` text NOT NULL, `t_download2` text NOT NULL, `t_download3` text NOT NULL, `t_ocr_text` text NOT NULL, `t_clean_ocr` tinyint(1) unsigned NOT NULL default '0', `t_markup1` text NOT NULL, `t_markup2` text NOT NULL, `t_orientation` char(1) NOT NULL default 'P', `t_spans_pages` tinyint(1) unsigned NOT NULL default '0', `t_date_captured` date NOT NULL default '0000-00-00', PRIMARY KEY (`fk_mno`,`st_id`), FULLTEXT KEY `short_name` (`short_name`), FULLTEXT KEY `t_ocr_text` (`t_ocr_text`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='One record per section or table'; -- -- Dumping data for table `sections` -- INSERT INTO `sections` VALUES (1, 6, 600, 1, 0, 0, 1, 1, '5. GENERAL TOTALS', '5. GENERAL TOTALS', 'Pages 6-7', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 7, 0, 0, 0, 0, 0, 0, 'Table awaiting title', 'Table awaiting title', 'Pages 4-5', 0, '', '', 'CDDA', 'A', '00100', '00004_TBL01_00005.XLS', 1, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 5, 500, 1, 0, 0, 1, 1, '4. OBSERVATIONS on some of the COLUMNS.', '4. OBSERVATIONS on some of the COLUMNS.', 'Page 7', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 4, 400, 1, 0, 0, 1, 1, '3. ARMY, NAVY, &c.', '3. ARMY, NAVY, &c.', 'Page 6', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 3, 300, 1, 0, 0, 1, 1, '2. COUNTIES IN WALES with particular OBSERVATIONS.', '2. COUNTIES IN WALES with particular OBSERVATIONS.', 'Pages 6-7', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 2, 200, 1, 0, 0, 1, 1, '1. COUNTIES IN ENGLAND with particular OBSERVATIONS.', '1. COUNTIES IN ENGLAND with particular OBSERVATIONS.', 'Pages 4-5', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 1, 100, 1, 0, 0, 1, 1, 'Title Page & Contents', 'Title Page & Contents', 'Pages 1-3', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 1, 100, 1, 0, 0, 1, 0, 'The Comparative Population of Great Britain 1801 and 1811 by county', 'The Comparative Population of Great Britain 1801 and 1811 by county', '3 pages', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 2, 200, 0, 0, 1, 2, 1, 'England', 'England', 'Page 1', 1, '', '', 'CDDA', 'A', '00100', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 3, 300, 0, 0, 1, 2, 1, 'Wales', 'Wales', 'Page 2', 1, '', '', 'CDDA', 'A', '00100', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 4, 400, 0, 0, 1, 2, 1, 'Scotland', 'Scotland', 'Page 2', 1, '', '', 'CDDA', 'A', '00100', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 5, 500, 1, 0, 1, 2, 1, 'Summary and Remarks', 'Summary and Remarks', 'Page 3', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 6, 600, 1, 0, 0, 1, 1, 'Title page', 'Title page', 'Page 4', 1, '', '', '', '', '', '', 0, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (4, 7, 0, 0, 0, 0, 0, 0, 'Table awaiting title', 'Table awaiting title', 'Pages 1-3', 0, '', '', 'CDDA', 'A', '00100', '00001_TBL01_00003.XLS', 1, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 8, 0, 0, 0, 0, 0, 0, 'Table awaiting title', 'Table awaiting title', 'Pages 6-7', 0, '', '', 'CDDA', 'A', '00100', '00006_TBL01_00007.XLS', 1, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00'); INSERT INTO `sections` VALUES (1, 9, 0, 0, 0, 0, 0, 0, 'Table awaiting title', 'Table awaiting title', 'Pages 6-7', 0, '', '', 'CDDA', 'A', '00100', '00006_TBL02_00007.XLS', 1, '', '', '', '', '', 0, '', '', 'P', 0, '0000-00-00');