AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   MySQL Query Help (https://forums.alliedmods.net/showthread.php?t=324979)

Weetabix 06-03-2020 14:40

MySQL Query Help
 
Hello brothers,

Just a little question about mysql and forgive me if this is the wrong place to ask this.
I use the follwing query to inset/update a value if the steamid is already present in the table. (SteamID is primary)

PHP Code:

INSERT INTO Table (SteamIDCreditsVALUES ('123''123'ON DUPLICATE KEY UPDATE Credits VALUES(Credits

However, I want to check if both steamid and another column exist together and then update the value as before. For example if Steami(123) and Credits(123) are present in the same row then update another value within that row. I just have no idea really on how to do it.

Thank you :)

DJ Tsunami 06-03-2020 14:56

Re: MySQL Query Help
 
You can create a primary key on multiple fields:

PHP Code:

CREATE TABLE Table (
    
SteamID ...,
    
Credits ...,
    
PRIMARY KEY (SteamIDCredits)


Or just create a unique index on both fields:

PHP Code:

CREATE UNIQUE INDEX Table_SteamID_Credits_idx
ON Table 
(SteamIDCredits


Weetabix 06-03-2020 15:08

Re: MySQL Query Help
 
Quote:

Originally Posted by DJ Tsunami (Post 2703833)
You can create a primary key on multiple fields:

PHP Code:

CREATE TABLE Table (
    
SteamID ...,
    
Credits ...,
    
PRIMARY KEY (SteamIDCredits)


Or just create a unique index on both fields:

PHP Code:

CREATE UNIQUE INDEX Table_SteamID_Credits_idx
ON Table 
(SteamIDCredits


Thank you DJ!


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

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