mysql插入不能用select into outfile?

时间:2013-04-01 15:52:58

标签: mysql insert

mysql> insert into helpme set user=(select 0x616361 into outfile 'c://windows//temp//test.ini');
Database changed

mysql> select * from helpme;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| user                                                                                                                                                                                                                                    | id    |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| a                                                                                                                                                                                                                                       |     1 |                                                                                                                                                                                                                                  | 37833 |
| aca                                                                                                                                                                                                                                     | 37834 |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
2 rows in set

为什么用户是aca?并且找不到文件(c://windows//temp//test.ini)?

1 个答案:

答案 0 :(得分:0)

SELECT … INTO … can’t be used in a sub-query

  

不应在嵌套INTO中使用SELECT子句,因为这样的SELECT必须将其结果返回到外部上下文。

这就是MySQL选择返回值而不是将其写入文件的原因。