table
id name telphone age
1 tom 138 12
2 bill 139 13
不能一步完成的方法是先查出来,再按需求插入
$data = $db->get_one("select * from table where name='tom' limit 1");
$db->query("insert into table(name,telphone,age) values('$data[name]','1388888‘,'$data[age]')");
Insert into table(name,telphone,age) select name,telphone,age from table where name='tom'
这句能正常使用完全复制值插入的
但是我想几个字段自定义值(如上例,telphone不用查询出来的值而是另外定义) 请问这语句该怎么改
先谢谢了!
1
caoyue 2015 年 4 月 21 日 Insert into table(name,telphone,age) select name,'1388888‘,age from table where name='tom'
|
3
caixiexin 2015 年 4 月 21 日 1l的方法为啥不行呢,是不是lz你自定义的值跟表字段不符?我记得以前我也是这么写的
|
4
liuhaotian 2015 年 4 月 21 日 via iPhone @jookr 他的一个引号不是英文的 你改了吗 应该没问题的。
提供下表结构 |
5
jookr OP |
7
bombless 2015 年 4 月 21 日 我晕,mysql里面反引号是用来围住名字(好像叫标识符)的,不能用来围住关键字。
话说楼主是呜呜吗? |