修复 MySQL Workbench 8 中的查询问题
我正在运行查询以更新表,但是它不会影响任何数据。我正在执行以下步骤: -
在MySQL中创建了一个具有列帐户的临时文件。 创建临时表tempfile(帐户varchar(20));
创建了一个只有四个帐号的CSV文件。此CSV文件是从XLSX格式转换的,每个数据都位于单独的行中。看起来完全像这个 22070601 22070701 22070801 21752301
现在,我使用命令将上述CSV数据文件上传到tempfile 加载数据本地流动的“ c:/testaccounts.csv”到表tempfile字段中,'\ t'终止 被''''\ n'终止的线所包含,忽略1行;
- n'的 线上; 更新tempfile set accounts = concat('0',帐户),其中帐户不为null;
我已经运行了查询以查看更新的数据。我看到所有帐号都与“ 0”联系 从tempfile;
中选择 *
输出: 022070601 022070701 022070801 021752301
- 后来我进行了查询,将帐户状态更改为“ A”的所有帐户的“ A”,其数字在tempfile
Update in tempfile Update in status status status ='a'where incore(从tempfile中选择帐户);
输出:查询是成功的,但是有0个更改
- 后,我再次从tempfile运行了查询选择 *; 输出已复制到记事本,我看到\ r连接到所有帐号 看起来
“ 022070601 \ r” '022070701 \ r' '022070801 \ r' '021752301 \ r'
我相信,由于帐号上有其他“ \ r”,我在第6点上的查询找不到在tempfile中找到任何类似帐户,无法将状态更改为'a';
有人,请在此问题上帮助我,以及当我将输出复制到NotPad时,帐户号中有“ \ r”。 我需要将帐户状态的状态更改为“ a”,具体取决于我的临时帐号。 Tempfile中的所有帐号都需要具有领先的“ 0”。
I am running a query to update the table however it's not impacting any data. I am doing the below steps:-
Created a temporary file in MySQL which has a column accounts.
CREATE TEMPORARY TABLE tempfile (accounts varchar(20));Created a CSV file that has only four account numbers. This CSV file is converted from xlsx format and each data is in a separate row. Look exactly like this-
22070601
22070701
22070801
21752301Now I have uploaded the above CSV data file to the tempfile using the command
LOAD DATA LOCAL INFILE "C:/testaccounts.csv" INTO TABLE tempfile FIELDS TERMINATED BY '\t'
ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS;I have concatenated '0' to all accounts using the query
UPDATE tempfile SET accounts = concat('0', accounts) where accounts IS NOT NULL;I have run a query to see the updated data. I see all the account numbers are contacted with '0'
SELECT *FROM TEMPFILE;
Output:
022070601
022070701
022070801
021752301
- Later I ran a query to change the status of the accounts to 'A' for all the accounts whose numbers are there in tempfile
update users set status = 'A' where account in (select account from tempfile);
Output: Query is successful but with 0 changes
- Later I again ran the query SELECT *FROM TEMPFILE;
The output is copied to a notepad and I see \r concatenated to all the account numbers
It looks like this
'022070601\r'
'022070701\r'
'022070801\r'
'021752301\r'
I believe because of additional '\r' in account numbers, my query on point 6 couldn't find any similar accounts in tempfile to change the status to 'A';
Someone, please help me on this issue and why there is '\r' in the account numbers when I copied the output to the notpad.
I need to change the status of my accounts to 'A' depending upon the account numbers in my tempfile. All the account number in tempfile need to have leading '0'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论