[SOLVED] Select data where there is no match...
Posted: Tue May 31, 2005 4:24 am
i have 2 tables
Table 1
and...
Currently i have this query
This selects all the main sections and their sub sections. Problem is, some of the main sections DO NOT have sub sections, so these main sections do not get selected in the query.
Is there some way i can do the query above, but modify it to add main sections that dont have a subsection!?
Or, will i have to have 2 querys?
Table 1
Code: Select all
CREATE TABLE `gha_files_sections` (
`id` int(10) NOT NULL auto_increment,
`section_name` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1Code: Select all
CREATE TABLE `gha_files_subsections` (
`id` int(2) NOT NULL auto_increment,
`subsection_name` varchar(255) default NULL,
`cid` int(2) default NULL,
`order` int(2) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1Code: Select all
SELECT s.id, s.section_name, ss.cid, ss.subsection_name
FROM ghaintranet.gha_files_sections AS s, ghaintranet.gha_files_subsections AS ss
WHERE (ss.cid = s.id) OR (s.id = 1)Is there some way i can do the query above, but modify it to add main sections that dont have a subsection!?
Or, will i have to have 2 querys?