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, null

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




Re: Hi and why

2003-01-21 Thread Paul DuBois
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, null

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




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, null
 
 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 Paul DuBois
At 16:47 -0200 1/21/03, Valdir Stiebe Junior wrote:

  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'.


That won't happen. MySQL performs extensive type conversion of values,
attempting to execute the query in the most sensible way given what you
provide.

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?

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).

If you're getting two rows with NAME = 2 and nothing with NAME = 0,
I'm at a loss to explain it.

-
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 Paul DuBois
At 18:11 -0200 1/21/03, Valdir Stiebe Junior wrote:

  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.


Yes, it is.  'ppl1' doesn't begin with digits, so it converts to zero
in numeric context.


 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 Dean Harding
I just tried it myself and I get an empty set as expected.

What do you get when you do a 'select * from test'?

 -Original Message-
 From: Valdir Stiebe Junior [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, 22 January 2003 5:48 am
 To: [EMAIL PROTECTED]
 Subject: Re: Hi and why
 
  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 mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
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 gerald_clark
ppl1 converted to numeric is 0.
You are compareing to a number.

Valdir Stiebe Junior wrote:


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, null

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


 




-
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 Gelu Gogancea
Hi,
Indeed...this happend in both main version of MySQL (ver. 3.x and 4.0.x)
However ,if you use :

select * from test_table where NAME='2';

you will have the correct result.

Regards,
Gelu
___
G.NET SOFTWARE COMPANY

Permanent e-mail address : [EMAIL PROTECTED]
  [EMAIL PROTECTED]
- Original Message -
From: Valdir Stiebe Junior [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 21, 2003 8:47 PM
Subject: Re: Hi and why


  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




-
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