社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  DATABASE

在MySQL中,我可以在同一个查询上使用“以开始的行”和“以结束的行”吗?

user157629 • 5 年前 • 1393 次点击  

我正在研究一个程序,它使用两个准备好的语句将一些数据复制到一个文本文件中( @aux1 @aux2 ). 然后在复制信息的表中,get删除所有行。

问题是当我使用 call copyIntoFile()

程序

delimiter !!
drop procedure if exists copyIntoFile !!
create procedure copyIntoFile()

begin
    declare path varchar(255);
    set path = concat("'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/", curdate(), ".txt'");

    set @aux1 = concat("select * from movie_modification where modified = true into outfile ", path, 
                        " fields terminated by ';' lines starting by 'Edit: ' lines terminated by '\n';");
    prepare stmt1 from @aux1;
    execute stmt1;
    deallocate prepare stmt1;

    set @aux2 = concat("select * from movie_modification where modified = false into outfile ", path, 
                        " fields terminated by ';' lines starting by 'New: ' lines terminated by '\n';");
    prepare stmt2 from @aux2;
    execute stmt2;
    deallocate prepare stmt2;

    delete from movie_modification;
end !!
delimiter ;

(执行过程时)

错误代码:1064。您的SQL语法有错误;请查看与MySQL服务器版本相对应的手册,在第1行的“以“”结尾的行”附近使用正确的语法

如您所见,错误发生在 lines terminated by (在第1行)。所以现在我想知道我能不能用 行终止于 之后 lines starting by

发生了什么?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/57312
 
1393 次点击  
文章 [ 1 ]  |  最新文章 5 年前