Mattias Håkansson wrote:
Hello,

I'm using MySQL 4.0.20 on Linux and I am experiencing some problems with a 
query result.

I have the following table structure:

mysql> desc gen_Lloyds_vessel;
+-----------------+----------+------+-----+---------------------+----------------+
| Field           | Type     | Null | Key | Default             | Extra         
 |
+-----------------+----------+------+-----+---------------------+----------------+
| iLloydsvesselID | int(11)  |      | PRI | NULL                | 
auto_increment |
| cName           | char(50) |      |     |                     |               
 |
| iImo            | int(11)  |      |     | 0                   |               
 |
| cCountry        | char(5)  |      |     |                     |               
 |
| iYearbuilt      | int(11)  |      |     | 0                   |               
 |
| cVesseltype     | char(40) |      |     |                     |               
 |
| iEnteredby      | int(11)  |      |     | 0                   |               
 |
| tEntered        | datetime |      |     | 0000-00-00 00:00:00 |               
 |
| iUpdatedby      | int(11)  |      |     | 0                   |               
 |
| tUpdated        | datetime |      |     | 0000-00-00 00:00:00 |               
 |
+-----------------+----------+------+-----+---------------------+----------------+
10 rows in set (0.00 sec)

Look at the query below:

mysql> SELECT cName,iImo FROM gen_Lloyds_vessel WHERE gen_Lloyds_vessel.iImo = 'FOOBAR'; +----------------------+------+
| cName | iImo |
+----------------------+------+
| SSG EDWARD A. CARTER | 0 |
| LYKES HERO | 0 |
| PONL GENOA | 0 |
| YM MILANO | 0 |
| PONL NEWARK | 0 |
| COSCO NORFOLK | 0 |
| PONL JAKARTA | 0 |
| PONL SYDNEY | 0 |
| PONL GENOA | 0 |
| PONL MARSEILLE | 0 |
+----------------------+------+
10 rows in set (0.07 sec)



None of these iImo fields has the value 'FOOBAR' but still I receive these results. Anyone have a clue what is causing this?

iImo is a numeric field, mysql knows it, and automagically converts the string 'FOOBAR' to a numeric value: 0. You are actually querying for iImo=0. Try this:


SELECT 'FOOBAR'+0,'FOOBAR'=0;

--
Roger


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to