修复 MySQL Workbench 8 中的查询问题

发布于 2025-01-17 22:08:26 字数 1092 浏览 3 评论 0原文

我正在运行查询以更新表,但是它不会影响任何数据。我正在执行以下步骤: -

  1. 在MySQL中创建了一个具有列帐户的临时文件。 创建临时表tempfile(帐户varchar(20));

  2. 创建了一个只有四个帐号的CSV文件。此CSV文件是从XLSX格式转换的,每个数据都位于单独的行中。看起来完全像这个 22070601 22070701 22070801 21752301

  3. 现在,我使用命令将上述CSV数据文件上传到tempfile 加载数据本地流动的“ c:/testaccounts.csv”到表tempfile字段中,'\ t'终止 被''''\ n'终止的线所包含,忽略1行;

  4. n'的 线上; 更新tempfile set accounts = concat('0',帐户),其中帐户不为null;

  5. 我已经运行了查询以查看更新的数据。我看到所有帐号都与“ 0”联系 从tempfile;

    中选择 *

输出: 022070601 022070701 022070801 021752301

  1. 后来我进行了查询,将帐户状态更改为“ A”的所有帐户的“ A”,其数字在tempfile

Update in tempfile Update in status status status ='a'where incore(从tempfile中选择帐户);

输出:查询是成功的,但是有0个更改

  1. 后,我再次从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:-

  1. Created a temporary file in MySQL which has a column accounts.
    CREATE TEMPORARY TABLE tempfile (accounts varchar(20));

  2. 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
    21752301

  3. Now 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;

  4. I have concatenated '0' to all accounts using the query
    UPDATE tempfile SET accounts = concat('0', accounts) where accounts IS NOT NULL;

  5. 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

  1. 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

  1. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文