Raised This Month: $ Target: $400
 0% 

help with sql


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 08-26-2009 , 11:56   Re: help with sql
Reply With Quote #10

Quote:
Originally Posted by |PJ| Shorty View Post
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).
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode