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 21752301
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;
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'.