php - How to UPDATE rows in one table where there duplictaes in another -
If someone can help me write a question to update our order system due to the cheat issue, Grateful on the scale
We have an order table and a customer table
I have identified some duplicate rows in the table of our customers where the email address and password are the same on unique lines - and the customer number Is present in the unique live order that exists in each table. This is bad when a customer enters their account, they will not see all their orders, rather they will only see orders related to the highest customer ID (see the entry below SQL)
Identify fake user accounts: Where do I start ?! Our system has been set up so that any new customer can be logged in by logging in to any customer. The related customer number is therefore about to actually fix the existing data. Update: I have never used SQL Fuel, but here are some sample data. I hope will help you .. help me Do it! Customers: CustomNumber, Email, Password 3272, jwilson@email.com, 9a098e0bade9b4f 2ac4ecdf86111cf7e 10001, jwilson@email.com, 9a098e0bade9b4f2ac4ecdf86111cf7e orders: ORDERNUMBER, CUSTOMERNUMBER, status < / em> 123,457, 3272, 'g' 123456, 10001, 'G' I need to ORDERNUMBER update: the CUSTOMERNUMBER of 123 457 10001 For, 3272 No. Step 1: Create a temporary column to store the correct customer number Step 2: Right CUSTOMERNUMBER retrieve Step 3: Correct CUSTOMERNUMBER Step 4: Delete the duplicate customer Step 5: Remove the Temp columns
select EMAILADDRESS, password, count (*) from join orders.customernumber = customers.CustomerNumber order scustomers where the EMAILADDRESS by = 1 Group , Passwords Counting (*) & gt; Select from: Where the email address: = Email address and password (password: = password)
update scustomers inner join (select EMAILADDRESS, password, scustomers group as Max (CUSTOMERNUMBER) ID Duplicate = Duplicate. EMailAdmin and scustomers.PASSWORD = Duplicate.psgword SET id_tmp = id on scustomers.emailaddress as password), by EMAILADDRESS;
Update orders with intermediate orders command: customer.customerNumber = customers.CustomerNumber set scribers include order order table.condition.customenumber = Id_tmp;
Remove from the customer, where the customcommand is & lt; & Gt; Id_tmp;
Optional table scouts drop column id_tmp;
Comments
Post a Comment