mysql5.1插入数据问题,请高手帮忙

winway_cd 2008-09-06 11:54:42
mysql5.1在插入整形类型的数据时,不能在用''号
insert into test(test_int,test_int1) values('1','2');
这条语句是5.0以前版本可用的,现在5.1用不了了,不知道各位高手是否有办法解决。
我不想该代码,应为这样的语句太多了。并且我也只能用5.1。
各位高手用捷径么?还请多多帮忙
...全文
120 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
winway_cd 2008-09-08
  • 打赏
  • 举报
回复
不好意思,问题描述错了。
应该是
insert into test(test_int,test_int1) values('1','');
是插入空的字段,以前用''是可以的。5。1现在不行,非要写成NULL.昨天我测试了。并且查了资料,没有办法解决该问题。不过谢谢各位。
wwwwb 2008-09-08
  • 打赏
  • 举报
回复
[Quote=引用楼主 wen800cn 的帖子:]
mysql5.1在插入整形类型的数据时,不能在用''号
insert into test(test_int,test_int1) values('1','2');
这条语句是5.0以前版本可用的,现在5.1用不了了,不知道各位高手是否有办法解决。
我不想该代码,应为这样的语句太多了。并且我也只能用5.1。
各位高手用捷径么?还请多多帮忙
[/Quote]
不会吧,我在5.1。37下测试没有问题,插入整形类型的数据时,最好
insert into test(test_int,test_int1) values(1,2);
懒得去死 2008-09-07
  • 打赏
  • 举报
回复
说说你的错误吧。

我机器上没有错误。

C:\Windows\system32>mysql -uroot -P3307 -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database t_girl;
Query OK, 1 row affected (0.07 sec)

mysql> use t_girl;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table girl_test (id int not null, num int unsigned not null);
Query OK, 0 rows affected (0.10 sec)

mysql> insert into girl_test values ('1','2');
Query OK, 1 row affected (0.00 sec)

mysql> select * from girl_test;
+----+-----+
| id | num |
+----+-----+
| 1 | 2 |
+----+-----+
1 row in set (0.00 sec)

iihero_ 2008-09-07
  • 打赏
  • 举报
回复
怎么可能呢,mysql这方面的兼容性非常好啊,你的5.1版本,具体子版本是多少?
我这里有最新5.1版本的测试,没有任何问题:
D:\mysql-5.1.26-rc-win32\bin>mysql -u test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.26-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show tables;
ERROR 1046 (3D000): No database selected
mysql> use test
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table test(id int, col2 int);
Query OK, 0 rows affected (0.11 sec)

mysql> insert into test values('1', '2');
Query OK, 1 row affected (0.03 sec)

mysql>
wildlily980 2008-09-07
  • 打赏
  • 举报
回复
估计楼主的分号是全角的.

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧