I am trying to do a left join query to retrieve all the rows in Table T1
and a value from server0000000001_history. 
There are 100 rows in T1 and I expect some NULL values for b.total 
returned from server0000000001_history.

Does anyone have any Idea why I only get back 93 rows with no nulls
when I should get 100 rows due to the nature of a left join?

I'm using MySQL version 3.23.34

SELECT a.* ,b.total 
FROM T1 a USE INDEX(PRIMARY) 
LEFT JOIN server0000000001_history b 
USE INDEX(PRIMARY) ON (a.crcid = b.crcid) 
WHERE b.tag=1 
AND b.day=11323;

CREATE TABLE `server0000000001_history` (
  `crcid` int(10) unsigned NOT NULL default '0',
  `tag` smallint(5) unsigned NOT NULL default '0',
  `day` int(10) unsigned NOT NULL default '0',
  `total` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`crcid`,`tag`,`day`),
) TYPE=MyISAM 

CREATE TABLE `T1` (
  `crcid` int(10) unsigned NOT NULL default '0',
  `sum` int(10) unsigned NOT NULL default '0',
  `item` mediumtext NOT NULL,
  PRIMARY KEY  (`crcid`)
) TYPE=MyISAM

Roger Karnouk
MediaHouse Software Inc.
[EMAIL PROTECTED]
http://www.mediahouse.com

MediaHouse Software Inc., leading developers of
LiveStats - Nonstop Web Reporting &
ipMonitor - 99.99% Uptime for your Networks


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to