Raised This Month: $ Target: $400
 0% 

help with sql


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 08-26-2009 , 11:05   Re: help with sql
Reply With Quote #9

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), `points` INT NOT NULL, PRIMARY KEY(`name`))
insert a name or if it exists update only the points:
Code:
 
INSERT INTO `something` (`name`,`points`) VALUES ('player',10) ON DUPLICATE KEY UPDATE `points`=100
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
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 08-26-2009 at 11:12.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
 



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