 |
|
Veteran Member
Join Date: Apr 2005
Location: Florida
|

08-26-2009
, 11:56
Re: help with sql
|
#10
|
Quote:
Originally Posted by |PJ| Shorty
if you are using mysql server >= v4.1 you can do this with one query.
example how i do in my plugins:
create a table with an unique field "name":
Code:
CREATE TABLE `something` (`name` VARCHAR(32),`SteamID` VARCHAR(34), `points` INT NOT NULL, PRIMARY KEY(`SteamID`))
insert a name or if it exists update only the points:
Code:
INSERT INTO `something` (`name`,`SteamID`,`points`) VALUES ('player','STEAM_x:x:xxxxxx',10) ON DUPLICATE KEY UPDATE `points`=100,`name`='player'
run the insert query twice and you will see, first the player is inserted with 10 points and second the points will be set to 100
|
*fixt
Have it check on steamid and update name based on that. (names can be repeated between players, steamids can't).
|
|
|
|