Raised This Month: $12 Target: $400
 3% 

Select second column if first is null


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-26-2016 , 16:24   Select second column if first is null
Reply With Quote #1

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
__________________

Last edited by skz; 05-26-2016 at 16:25.
skz is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-26-2016 , 16:27   Re: Select second column if first is null
Reply With Quote #2

Two threads my guy.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-26-2016 , 16:30   Re: Select second column if first is null
Reply With Quote #3

Quote:
Originally Posted by EFFx View Post
Two threads my guy.
Two threads? I think that might be an option to select in one thread
__________________
skz is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-26-2016 , 16:31   Re: Select second column if first is null
Reply With Quote #4

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.
__________________
Black Rose is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-26-2016 , 16:51   Re: Select second column if first is null
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
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
__________________
skz is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-26-2016 , 17:01   Re: Select second column if first is null
Reply With Quote #6

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.
__________________

Last edited by Black Rose; 05-26-2016 at 17:04.
Black Rose is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-26-2016 , 17:10   Re: Select second column if first is null
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
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
__________________
skz is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-26-2016 , 17:25   Re: Select second column if first is null
Reply With Quote #8

There's literally no reason to save by IP, even with Dproto.
__________________
gabuch2 is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-26-2016 , 19:27   Re: Select second column if first is null
Reply With Quote #9

Quote:
Originally Posted by Shattered Heart Lynx View Post
There's literally no reason to save by IP, even with Dproto.
You didn't read what I writed
__________________
skz is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-27-2016 , 00:02   Re: Select second column if first is null
Reply With Quote #10

Try
Code:
SELECT Iif(slotitem1 Is Null, slotitem2, slotitem1) As Item
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 21:17.


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