Insert value “0″ for primary keys with auto increment in MySQL

July 12, 2009 – 22:11

In order to insert value 0 in a field that is set as primary key for a MySQL table you need to execute the following query prior to any insert query:

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

Now you can successfully run the insert query with 0 set as value for a primary key, without getting any error message.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • Facebook
  • BlinkList
  • Fark
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • LinkedIn
  • Mixx
  • MySpace
  • Google Bookmarks
  • Live
  • Yahoo! Buzz
  • DZone
  • Twitter
  • Yahoo! Bookmarks

Tags: , , , ,

Post a Comment