Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Sat May 13, 2006 7:54 am
I set a column to not null, yet it is still accepting null values... is white space a value?
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sat May 13, 2006 9:08 am
white space, "", " ", '', ' ' are not equal to NULL.
ps: Even NULL isn't equal to NULL
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Sat May 13, 2006 10:17 am
Ah I see.... is there a way to go about this?
Basically i'm using one page to add and update, so i have a select clause, and if column B doesnt exist, it will add.. or else it will update if it does exist.. the problem is that it is always seeing it as existing because it is creating empty space...
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sat May 13, 2006 10:24 am
Handle it at the php side..
If strlen($input) == 0 -> generate query with NULL value , otherwise generate query with $input
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Sat May 13, 2006 1:49 pm
timvw wrote: Handle it at the php side..
If strlen($input) == 0 -> generate query with NULL value , otherwise generate query with $input
try a trigger before update on the column in the table and make empty values to NULL. It will be cool.
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sat May 13, 2006 6:07 pm
Untill the day i really want to add just ''
I appreciate that a dbms validates my data, but usually i do not appreciate when it decided to modify it..