NOT NULL Fields

2003-01-22 Thread Valdir Stiebe Junior
Hi,
Creating a table with a not null field, and then trying to insert it doesn't
raise an error 'Column XXX cannot be null'
Well, this was the steps (sql to bypass filter) i did:

1. create table TEST ( id_test integer, name varchar(50) not null );
2. insert into TEST (id_test, name) values (1, 'ppl1');  (ok it works)
3. insert into TEST (id_test, name) values (2, NULL); (ok raise an error)
4. insert into TEST (id_test) values (3); (insert a row with name = '')

This is correct? A bug? Or i'm to worried about raising errors? :)

TIA


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Hi and why

2003-01-21 Thread Valdir Stiebe Junior
> I'm stlll surprised that NAME = 2 returns anything.  When I tried your
> example, it returned no rows.  I get two rows with NAME = 0, nothing
> with NAME = 2.  Are you sure you're not mixing up your test results?

Sorry, my mistake.

> NAME = 0 is a string-to-number conversion.  MySQL converts the string
> to a number and performs a numeric comparison.  Of your three values,
> 'ppl1' and 'ppl2' will be converted to 0 (which compares the same as 0),
> but NULL is still NULL (which does not compare the same as 0).

Ok, i understand now. This is useful when you have things like '10' or
'342'. But when you have 'ppl1' isn't deterministic wich number it
represent. But thanks. I'm studying to understand how MySql works.

I have another question, will open another thread to it.

Thanks.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Hi and why

2003-01-21 Thread Valdir Stiebe Junior
Sorry, correcting my last email, the sql result the two rows when i use
'NAME = 0'.

- Original Message -
From: "Paul DuBois" <[EMAIL PROTECTED]>
To: "Valdir Stiebe Junior" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, January 21, 2003 4:33 PM
Subject: Re: Hi and why


> At 15:02 -0200 1/21/03, Valdir Stiebe Junior wrote:
> >Hi, i'm new at this list and to the mysql world. I'm a delphi/firebird
> >developer and have to acomplish some tasks using a mysql based database.
So
> >i'm looking about how things work in mysql.
> >
> >My question... i created a table TEST, with two columns, ID_TEST int(11)
and
> >NAME varchar(50).. and  added three records. This way:
> >
> >1, "ppl1"
> >2, "ppl2"
> >3, 
> >
> >ok.. why when i execute this sql, mysql return the two first rows,
instead
> >of raising an error?
> >
> >select * from TEST where NAME = 2??
>
> I don't know why it returns the first two rows, but (assuming you didn't
> really end your query with two question marks) what error are you
expecting
> to occur?
>
> >
> >TIA.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Hi and why

2003-01-21 Thread Valdir Stiebe Junior
> I don't know why it returns the first two rows, but (assuming you didn't
> really end your query with two question marks) what error are you
expecting
> to occur?

I didn't end my query with the two question marks. :)
And if i put 0 instead of (2 or any different of zero) after the equal sign
the sql return nothing. (better than returning garbage)
I was expecting something like 'Column NAME isn't of type integer'.



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Hi and why

2003-01-21 Thread Valdir Stiebe Junior
Hi, i'm new at this list and to the mysql world. I'm a delphi/firebird
developer and have to acomplish some tasks using a mysql based database. So
i'm looking about how things work in mysql.

My question... i created a table TEST, with two columns, ID_TEST int(11) and
NAME varchar(50).. and  added three records. This way:

1, "ppl1"
2, "ppl2"
3, 

ok.. why when i execute this sql, mysql return the two first rows, instead
of raising an error?

select * from TEST where NAME = 2??

TIA.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php