ohdang888 Posted July 5, 2008 Share Posted July 5, 2008 $mb = mysql_query("SELECT * FROM `message_board`,`message_read` WHERE `message_board.per_code`='$rep_p' AND (`message_board.state`='$rep_state' OR `message_board.state`='ALL') AND (`message_read.u_id`!='$user' AND `message_read.m_id` != `message_board.id`) ")or die(mysql_error()); Unknown column 'message_board.per_code' in 'where clause' but i assure, all of all is spelled correctly, and yes, a column of "per_code" actually exists in the table of "message_board" any ideas?thanks! Link to comment https://forums.phpfreaks.com/topic/113327-solved-stuck-on-mysql-query/ Share on other sites More sharing options...
wildteen88 Posted July 5, 2008 Share Posted July 5, 2008 You must of typed something incorrectly. Double check to make sure everything is spelled correctly (your query and your database). You may have made a mistake when creating the table/columns in the database, for example per_code may be typed like par_code something silly like that. Also avoid using SELECT * in your query. List your columns. Link to comment https://forums.phpfreaks.com/topic/113327-solved-stuck-on-mysql-query/#findComment-582258 Share on other sites More sharing options...
teynon Posted July 5, 2008 Share Posted July 5, 2008 How are you mergin the two tables? What in message_board lines up with message_read? message_board.id = message_read.UserID? Link to comment https://forums.phpfreaks.com/topic/113327-solved-stuck-on-mysql-query/#findComment-582260 Share on other sites More sharing options...
ohdang888 Posted July 5, 2008 Author Share Posted July 5, 2008 CREATE TABLE `message_board` ( `id` int(11) NOT NULL auto_increment, `per_code` int(2) NOT NULL, `message` varchar(500) NOT NULL, `by` bigint(20) NOT NULL, `state` varchar(2) NOT NULL, `date` varchar(20) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) and CREATE TABLE `message_read` ( `id` int(11) NOT NULL auto_increment, `m_id` int(11) NOT NULL, `u_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) those are the tables, the SQL just exported... unless i'm blind, which i could be, there's nothing misspelled Link to comment https://forums.phpfreaks.com/topic/113327-solved-stuck-on-mysql-query/#findComment-582265 Share on other sites More sharing options...
wildteen88 Posted July 5, 2008 Share Posted July 5, 2008 Doh! Just noticed whats up, it's to do with the backticks MySQL is trying to find a column called message_board.per_code not the column per_code within the message_board table. This: `message_board.per_code` should be witten as `message_board`.`per_code` Only the table/column name needs to be in backticks not the period. Link to comment https://forums.phpfreaks.com/topic/113327-solved-stuck-on-mysql-query/#findComment-582268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.