Hello,
I'm having some problems with a join I've been trying. Here's the table structure
CREATE TABLE `business` ( `b_id` int(5) NOT NULL auto_increment, `b_name` varchar(100) default NULL, `b_contact` varchar(100) default NULL, `b_address` varchar(100) default NULL, `b_city` varchar(50) default NULL, `b_state` char(2) default NULL, `b_zip` varchar(25) default NULL, `b_phone` varchar(20) default NULL, `b_fax` varchar(20) default NULL, `b_dcn` varchar(10) default NULL, PRIMARY KEY (`b_id`) ) TYPE=MyISAM;
CREATE TABLE `packages` ( `p_id` int(5) NOT NULL auto_increment, `p_name` varchar(75) default NULL, PRIMARY KEY (`p_id`) ) TYPE=MyISAM;
CREATE TABLE `records` ( `r_id` int(5) NOT NULL auto_increment, `r_b_id` int(5) default NULL, `r_p_id` int(5) default NULL, `r_sold` tinyint(1) default NULL, `r_date` year(4) default NULL, PRIMARY KEY (`r_id`) ) TYPE=MyISAM;
I've worked out this to retrieve records based on a package id and year.
SELECT * FROM records AS r LEFT JOIN business AS b on (b.b_id=r.r_b_id) LEFT JOIN packages AS p on (p.p_id=r.r_p_id) WHERE p_id='16' AND r_date = '2004';
Here's where I'm having trouble. I also need to retrieve all the businesses not in the results of the above query. I've been playing around with this for a couple of days now with no luck. Any help would be greatly appreciated.
Thanks in advance, Mike
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]