MySQL unknown column (is in table) -
my table structure:
inventory_items:
create table `inventory_items` ( `id` int(10) unsigned not null auto_increment, `name` varchar(50) default null comment 'usually used invoice number', `vendor_id` int(10) not null default '1', `item_type_id` int(10) unsigned default null, `item_model_id` int(10) unsigned default null, `condition_id` int(10) unsigned default null, `item_functionality_id` int(10) unsigned default null, `color_id` int(10) unsigned default null, `quantity` int(10) unsigned default null, `original_qty` int(10) default null, `note` text, `zone_id` int(10) unsigned default null, `rack_id` int(10) unsigned default null, `shelf_id` int(10) unsigned default null, `bin_id` int(10) unsigned default null, `status` char(1) default null comment '1:checkedin;2:transferred', `reserve` tinyint(1) not null default '0', `log` text, `user_id` int(10) unsigned default null, `created` datetime default null, `modified` datetime default null, `item_manu_model_id` int(11) not null default '0', `cdma_carrier_id` int(11) default '0', primary key (`id`) ) engine=innodb auto_increment=45334 default charset=latin1
my sql-query:
select inventory_items.id, conditions.`name`, item_models.`name` inventory_items, sorting_reports inner join item_models on inventory_items.item_model_id = item_models.id inner join conditions on inventory_items.condition_id = conditions.id inventory_items.item_model_id = 1111 , inventory_items.condition_id = 10 , inventory_items.id = 20 , ( ( inventory_items.zone_id = 21 ) or ( inventory_items.rack_id = 175 ) ) , sorting_reports.id != 0
and following error:
[err] 1054 - unknown column 'inventory_items.item_model_id' in 'on clause'
the column existing.... :(
short answer: mixing join types. use inner join
or ,
notation, not both. reason: compiler attempts complete inner join statements first before generating possibly large cartesian on ,
type join. @ time join attempted, has no knowledge of value in question. if mean cross join state , problem should go away.
more on can found: what difference between using cross join , putting comma between 2 tables?
select inventory_items.id, conditions.`name`, item_models.`name` inventory_items cross join sorting_reports inner join item_models on inventory_items.item_model_id = item_models.id inner join conditions on inventory_items.condition_id = conditions.id inventory_items.item_model_id = 1111 , inventory_items.condition_id = 10 , inventory_items.id = 20 , ( ( inventory_items.zone_id = 21 ) or ( inventory_items.rack_id = 175 ) ) , sorting_reports.id != 0
Comments
Post a Comment