View Single Post

   
  #7 (permalink)  
Old 02-28-2008, 10:08 AM
Rik
 
Posts: n/a
Default Re: SELECT errors out saying a column doesn't exist that SHOW COLUMNS thinks does exist

On Sat, 10 Feb 2007 02:41:12 +0100, Rik <luiheidsgoeroe@hotmail.com> wrote:

> On Sat, 10 Feb 2007 02:18:52 +0100, yawnmoth <terra1024@yahoo.com> wrote:
>
>> On Feb 9, 3:04 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
>>> <snip>
>>> What does a SHOW CREATE TABLE `ip_adresses` show?

>>
>> [Table] => phpbb_proxies
>> [Create Table] => CREATE TABLE `ip_addresses` (
>> `ip_address` varchar(8) NOT NULL default '',
>> `behavior` tinyint(2) NOT NULL default '0',
>> `port ` varchar(4) default '0',

>
> Did you spot the space (or maybe it's another whitespace character)?
>
> SELECT `port ` FROM `phpbb_proxies`
>
> Another fine reason to always use backticks


Hmmz, I'm actually curious how this came to be. My MySQL 5.0 won't let me
create it.

If you're still having troubles selecting from it with a space I suspect
it's some weird character. Easiest way to solve it:

CREATE TABLE `ip_addresses_temp` (
`ip_address` varchar(8) NOT NULL default '',
`behavior` tinyint(2) NOT NULL default '0',
`port` varchar(4) default '0',
`last_checked` int(11) NOT NULL default '0',
PRIMARY KEY (`ip_address`)
) TYPE=MyISAM

INSERT INTO `ip_addresses_temp` SELECT * FROM `ip_addresses`

DROP TABLE `ip_addresses`

RENAME TABLE ip_addresses_temp TO ip_addresses

--
Rik Wasmus
Reply With Quote