我有这个MySQL查询
SELECT count( * ) AS total
FROM `orders` o, `orders_status` s, `orders_status_history` osh
LEFT JOIN `orders_total` ot ON ot.orders_id = o.orders_id
WHERE o.orders_status = s.orders_status_id
AND osh.orders_id = o.orders_id
AND s.language_id = '5'
AND s.orders_status_id = '6'
AND ot.class = 'ot_total'
收到此错误:
#1054 - Unknown column 'o.orders_id' in 'on clause'
我的表架构如下:
CREATE TABLE IF NOT EXISTS `orders` (
`orders_id` int(11) NOT NULL auto_increment,
`customers_id` int(11) NOT NULL default '0',
`last_modified` datetime default NULL,
`orders_status` int(5) NOT NULL default '0',
`orders_date_finished` datetime default NULL,
`comments` text,
`currency` char(3) default NULL,
`currency_value` decimal(14,6) default NULL,
`invoice_number` varchar(100) default NULL,
PRIMARY KEY (`orders_id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=8419 ;
而且我不明白错误来自哪里。有任何想法吗?