tags:

views:

35

answers:

1

Consider the table schema for table1:

id: int
country_id: int
description: varchar(50)

and the query:

INSERT INTO table1(id, country_id, description) VALUES (1, '20', 'Test Desc'); 

This would work under MySQL 4x but will fail under MySQL 5x (ERROR 1067 (42000): Invalid default value for .. ").

I know the reason for this to happen - country_id is int and therefore should not be quoted. Is there a mysql switch under 5x somewhere to make it behave like 4x so the query won't fail?

I've inherited an application that uses queries like this and I'm looking for a quick fix until I can find the time to fix all the queries.

Thank you

+1  A: 

There is no problem with '20'. MySql (5.x) also casts '20' to 20 and => this is a valid insert

Svetlozar Angelov