AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Select second column if first is null (https://forums.alliedmods.net/showthread.php?t=283156)

skz 05-26-2016 16:24

Select second column if first is null
 
Hi guys

How can I select another column if the first one is null?

PHP Code:

WHERE IFNULL(`slotitem1`,`slotitem2`) = ('%s','%s'

I tryed this way but it doesnt work

EFFx 05-26-2016 16:27

Re: Select second column if first is null
 
Two threads my guy.

skz 05-26-2016 16:30

Re: Select second column if first is null
 
Quote:

Originally Posted by EFFx (Post 2422245)
Two threads my guy.

Two threads? I think that might be an option to select in one thread

Black Rose 05-26-2016 16:31

Re: Select second column if first is null
 
I don't understand really. Do you want to skip NULL entries?
Code:

/**
 * Tells whether a specific column in the current row
 *  is NULL or not.
 */
native SQL_IsNull(Handle:query, column);

Is that helpful?

Or perhaps this:
http://www.w3schools.com/sql/sql_null_values.asp

P.S. If you delete your other post the whole thread will be gone unless someone replies to it.

skz 05-26-2016 16:51

Re: Select second column if first is null
 
Quote:

Originally Posted by Black Rose (Post 2422247)
I don't understand really. Do you want to skip NULL entries?
Code:

/**
 * Tells whether a specific column in the current row
 *  is NULL or not.
 */
native SQL_IsNull(Handle:query, column);

Is that helpful?

Or perhaps this:
http://www.w3schools.com/sql/sql_null_values.asp

P.S. If you delete your other post the whole thread will be gone unless someone replies to it.

Imagine, I want to select the second Item if the first isn't detected on the table, but if the first is detected, dont select the second

Black Rose 05-26-2016 17:01

Re: Select second column if first is null
 
That is not explanatory at all. If anything you made it harder to understand. I think I get the point though.

In your other post you named them SteamID and IP, which means you want to use SteamID whenever possible and IP otherwise. This is a problem directly caused by dproto at which point I don't care.

skz 05-26-2016 17:10

Re: Select second column if first is null
 
Quote:

Originally Posted by Black Rose (Post 2422260)
That is not explanatory at all. If anything you made it harder to understand. I think I get the point though.

In your other post you named them SteamID and IP, which means you want to use SteamID whenever possible and IP otherwise. This is a problem directly caused by dproto at which point I don't care.

Yeah, I didnt post that because someone like you could think the same, but no, its because sometimes my server dont record steam id and I dont know why so i'm trying to select IP if is that case (sorry for my english). I know that isnt the best way but until I solve it I cant do nothing beside this

gabuch2 05-26-2016 17:25

Re: Select second column if first is null
 
There's literally no reason to save by IP, even with Dproto.

skz 05-26-2016 19:27

Re: Select second column if first is null
 
Quote:

Originally Posted by Shattered Heart Lynx (Post 2422268)
There's literally no reason to save by IP, even with Dproto.

You didn't read what I writed

Bugsy 05-27-2016 00:02

Re: Select second column if first is null
 
Try
Code:

SELECT Iif(slotitem1 Is Null, slotitem2, slotitem1) As Item


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

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