AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Question about MySql (https://forums.alliedmods.net/showthread.php?t=128192)

Kiske 05-29-2010 18:08

Question about MySql
 
How I can detect between a query if the date is repited in another "column" of the data base?

Example:
Quote:

Nick -- Money
Kiske 16000
Nanna 16000
Pipu 14389
Lole 10890

Kiske and Nanna have U$S 16000


Alka 05-29-2010 18:21

Re: Question about MySql
 
Maybe you find something useful here.I think "distinct" should be the solution or w/e (this is in case you want to select only entryes that have the distinct 'money' value')

Sylwester 05-29-2010 18:27

Re: Question about MySql
 
Try this:
PHP Code:

public get_money(id){
    static 
cache[256], data[2]
    new 
money 16000
    formatex
(cache255,"SELECT Nick FROM table_name WHERE Money=%d;"money)
    
data[0] = money
    SQL_ThreadQuery
(g_SqlTuple"handle_get_money_query"cachedata1)
    return 
PLUGIN_HANDLED
}


public 
handle_get_money_query(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    static 
name[32], money
    
if(FailState){
        
log_amx("SQL Error: %s (%d)"ErrorErrcode)
        return 
PLUGIN_HANDLED
    
}

    
money Data[0]
    while(
SQL_MoreResults(Query)){
        
SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"Nick"), name31)
        
client_print(0print_chat"%s has %d money"namemoney)
        
SQL_NextRow(Query)
    }
    return 
PLUGIN_CONTINUE



Alka 05-29-2010 18:29

Re: Question about MySql
 
He want to detect if in the column 'Money', there are 2 or more entryes with the same value...

Kiske 05-29-2010 18:34

Re: Question about MySql
 
Quote:

Originally Posted by Sylwester (Post 1194741)
Try this:
PHP Code:

public get_money(id){
    static 
cache[256], data[2]
    new 
money 16000
    formatex
(cache255,"SELECT Nick FROM table_name WHERE Money=%d;"money)
    
data[0] = money
    SQL_ThreadQuery
(g_SqlTuple"handle_get_money_query"cachedata1)
    return 
PLUGIN_HANDLED
}


public 
handle_get_money_query(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    static 
name[32], money
    
if(FailState){
        
log_amx("SQL Error: %s (%d)"ErrorErrcode)
        return 
PLUGIN_HANDLED
    
}

    
money Data[0]
    while(
SQL_MoreResults(Query)){
        
SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"Nick"), name31)
        
client_print(0print_chat"%s has %d money"namemoney)
        
SQL_NextRow(Query)
    }
    return 
PLUGIN_CONTINUE



No, sorry, but that's not what I want.
I want to query for PhpMyAdmin and I show it from there, not from a plugin, sorry.

And sorry but I am very bad at English


I do not want the query:
SELECT * FROM money WHERE `date` = '16000'

For the 16000 was an example, I want to show me their recurrence.

Brreaker 05-30-2010 02:25

Re: Question about MySql
 
Well, here you will find only scripting help.If you want some website, not the right place...

Exolent[jNr] 05-31-2010 03:35

Re: Question about MySql
 
This has nothing to do with AMXX scripting.
MySQL is it's own queries and isn't dependent on AMXX.


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

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