A
A
AcidZer02015-09-21 00:29:03
MySQL
AcidZer0, 2015-09-21 00:29:03

How to write mysql query correctly?

You need to make a request. First, in the hlstatsx.hlstats_PlayerUniqueIds table, you need to select all the rows that contain the tf value in the game field, as well as those that do not fit the '[U:%' mask.
Then you need to read the values ​​of the playerid column in the selected rows. Next, you need to find matches in the entire hlstatsx table for this field, as well as for the killerId and victimId fields, and delete them along with those that have already been selected. Then return to hlstatsx.hlstats_PlayerUniqueIds, and convert the uniqueid field values ​​according to the following principle: the field value consists of [U: xxxyyy], first we discard the excess, xxxyyy remains (digital value), we divide it by two and discard the fractional part. I have never come across C mysql, I don’t even know about which edge to approach.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AcidZer0, 2015-09-22
@AcidZer0

USE hlstatsx;
CREATE TABLE tmp_PlayerIds(playerId INT);
INSERT INTO tmp_PlayerIds
SELECT playerId
FROM hlstats_PlayerUniqueIds
WHERE game = 'tf'
AND uniqueId NOT LIKE '[U:%';
DELETE FROM hlstats_Players WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_PlayerNames WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_PlayerUniqueIds WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Players_Awards WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Players_History WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Players_Ribbons WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_ChangeName WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_ChangeTeam WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Connects WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Disconnects WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Frags WHERE killerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Frags WHERE victimId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Latency WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Entries WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_PlayerActions WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Suicides WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_TeamBonuses WHERE playerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Teamkills WHERE killerId IN (SELECT playerId FROM tmp_PlayerIds);
DELETE FROM hlstats_Events_Teamkills WHERE victimId IN (SELECT playerId FROM tmp_PlayerIds);
DROP TABLE tmp_PlayerIds;
UPDATE hlstats_PlayerUniqueIds
SET uniqueId = concat(MOD(SUBSTRING(uniqueId,6,9),2), ':', FLOOR(SUBSTRING(uniqueId,6,9)/2))
Comrade pogromist helped.

O
OnYourLips, 2015-09-21
@OnYourLips

Read the documentation, start here: https://dev.mysql.com/doc/refman/5.6/en/select.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question