Try this: mysql> insert into t (a) values (if(char_length("sbd"), "sbd", NULL)); Query OK, 1 row affected (0.47 sec)
mysql> insert into t (a) values (if(char_length(""), "sbd", NULL)); ERROR 1048 (23000): Column 'a' cannot be null Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 > -----Original Message----- > From: js [mailto:[EMAIL PROTECTED] > Sent: Monday, February 12, 2007 11:09 AM > To: Rolando Edwards > Cc: mysql@lists.mysql.com > Subject: Re: NOT EMPTY, like NOT NULL > > Thanks for reply and sorry for lack of information. > > What I want to know is not how to query, > but how to prevent emtpy data from being inserted in tables. > > Let's say I'd like to have a table that doesn't contains any > NULL value. > I'd create the table like below. > > ################################## > mysql> create table t (a char(10) not null); > create table t (a char(10) not null); > Query OK, 0 rows affected (0.07 sec) > > mysql> insert into t values(NULL); > insert into t values(NULL); > ERROR 1048 (23000): Column 'a' cannot be null > ################################## > > well, looks good, > but NOT NULL only prevent NULL, as the name implied. > > > ################################## > mysql> insert into t values(''); > Query OK, 1 row affected (0.00 sec) > > mysql> select * from t; > select * from t; > +---+ > | a | > +---+ > | | > +---+ > 1 row in set (0.01 sec) > ################################### > > Is there any easy way to implement 'NOT EMPTY' constraint? > > Thank you in advance. > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]