I have an csv importer for 3 files so that my game statistics can be updated quickly. After a while I realised it was inserting the same data into multiple columns in the database.
I am trying to update data inside one of the tables using an UPDATE
statement.
The five columns I need fixed are data1, data2, data3, hits, totalnum.
If the user is a valid player then I need hits and totalnum set to 0.
If they are not a valid player than I need data1, data2
and data3
set to 0.
To check users valid I need to access users table and lookup the users details and check the is_valid column.
I may have to do 2 queries for this, 1 for valid users and 1 for non-valid users.
What I have so far doesn't check users table and i don't know how to do this.
UPDATE game_stats
SET data1 = 0,
data2=0,
data3=0
WHERE data1 <= 1 AND data2 <= 1 AND data3 <= 1
Users table
Id, fname, lname, is_valid, detailsGame_stats
Id, userid, data1, data2, data3, hits, totalnum
Please could someone help me do this?