jordanwb Posted February 2, 2009 Share Posted February 2, 2009 This is the query I'm trying to run: SELECT * FROM `j_categories` INNER JOIN `j_records` ON `j_categories.category_id` = `j_records.record_category_id` These are the table structures: CREATE TABLE `j_categories` ( `category_id` int(10) unsigned NOT NULL auto_increment, `category_name` varchar(32) NOT NULL, PRIMARY KEY (`category_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE `j_records` ( `record_id` int(11) NOT NULL auto_increment, `record_category_id` int(10) unsigned NOT NULL, `record_name` varchar(64) NOT NULL, `record_cost` double(5,2) NOT NULL, `record_has_gst` tinyint(1) NOT NULL, `record_has_pst` tinyint(1) NOT NULL, `record_date` date NOT NULL, PRIMARY KEY (`record_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; The error: Unknown column 'j_categories.category_id' in 'on clause' :-\ Quote Link to comment https://forums.phpfreaks.com/topic/143531-solved-unknown-column-j_categoriescategory_id-in-on-clause/ Share on other sites More sharing options...
corbin Posted February 3, 2009 Share Posted February 3, 2009 `j_categories.category_id` means a table named "j_categories.category_id" I believe you're looking for `j_categories`.`category_id` Or, just don't use the backticks. They break MSSQL compatibility (and other SQL flavors too), and they're useless unless your column has a reserved name, which it shouldn't. Quote Link to comment https://forums.phpfreaks.com/topic/143531-solved-unknown-column-j_categoriescategory_id-in-on-clause/#findComment-753190 Share on other sites More sharing options...
jordanwb Posted February 3, 2009 Author Share Posted February 3, 2009 Or, just don't use the backticks. They break MSSQL compatibility (and other SQL flavors too), and they're useless unless your column has a reserved name, which it shouldn't. I'll keep that in mind. I removed the backticks the query works. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/143531-solved-unknown-column-j_categoriescategory_id-in-on-clause/#findComment-753215 Share on other sites More sharing options...
corbin Posted February 3, 2009 Share Posted February 3, 2009 No problem ;p. Quote Link to comment https://forums.phpfreaks.com/topic/143531-solved-unknown-column-j_categoriescategory_id-in-on-clause/#findComment-753231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.