E
E
eldar_web2016-04-01 17:16:56
MySQL
eldar_web, 2016-04-01 17:16:56

How can two records be compared in SQL (MySQL) by removing unnecessary things from the records?

It so happened that when entering data into the database, the following situation occurred: there are fields price (accrued) and price_paid (paid), and the amount was entered in price in this way: 99.95 (correct), and in price_paid: 9995.0 (wrong).
Right now I want to fix it, but to do this, display where, according to the idea, price and price_paid are equal and fix it. How can you compare and output them? It doesn't work like this: (price = price_paid)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eldar_web, 2016-04-01
@eldar_web

SELECT * FORM table WHERE price_paid = REPLACE(price, '.','');

D
Dmitry Kovalsky, 2016-04-01
@dmitryKovalskiy

UPDATE table1 
SET price = t2.price_paid
FROM table1 as t1
INNER JOIN table2 as t2 ON .t1.priceId = t2.priceId

You can also try like this. This is with strong and varied discrepancies, but I don’t know if such an entry works on MySql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question