MySQL Insert Data Question

Posted by Nano HE on Stack Overflow See other posts from Stack Overflow or by Nano HE
Published on 2010-05-05T02:47:35Z Indexed on 2010/05/05 2:58 UTC
Read the original article Hit count: 239

Filed under:
|
|

Hi, assume I already created a table in MySQL as below

CREATE TABLE IF NOT EXISTS `sales` (
  `id` smallint(5) unsigned NOT NULL auto_increment,
  `client_id` smallint(5) unsigned NOT NULL,
  `order_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `sub_total` decimal(8,2) NOT NULL,
  `shipping_cost` decimal(8,2) NOT NULL,
  `total_cost` decimal(8,2) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `sales`
--

If I added a new field must_fill for the current table.

 `must_fill` tinyint(1) unsigned NOT NULL,

User can insert less than the number of fiels items to the table defaultly, just as the script of below.

INSERT INTO `sales` (`id`, `client_id`, `order_time`, `sub_total`, `shipping_cost`, `total_cost`) VALUES
(8, 12312, '2007-12-19 01:30:45', 10.75, 3.00, 13.75);

It's fine.

But How can I configure the field (must_fill) to a MUST INCLUDE Data field when user plan to insert into new data.

BTW, The code will be integrated in PHP script.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql