From: "Rochester, Dean" <[EMAIL PROTECTED]>

> I have a Mysql table with a char(2) column, name is Dependents.  I want
the
> value that I insert to always be to places.  I have tried
>
> Insert into Table1 Dependents values '02';
>
> but it inserts  2 in the Dependents column
>
> How do I make it insert  02?


Is the value being inserted with quotes?

Try this:

------------------------------------------
CREATE TABLE foo (
    test CHAR(2)
);

INSERT INTO foo SET test='02';
INSERT INTO foo SET test="02";
INSERT INTO foo SET test=02;

SELECT * FROM foo;

DROP TABLE foo;
------------------------------------------

This returns:

------------------------------------------
+------+
| test |
+------+
| 02   |
| 02   |
| 2    |
+------+
3 rows in set (0.00 sec)

------------------------------------------


The first two times insert fine, when using single- or double-quotes, but
when quotes aren't used, I think MySQL assumes it's an integer and trims
leading zeros.

Hope this helps!


--
denonymous
www.coldcircuit.net



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

Reply via email to