Click here to Skip to main content
15,116,654 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: get getter and get setter, or is it getter get and getter set? Pin
V.29-Aug-17 20:03
professionalV.29-Aug-17 20:03 
GeneralCSS fun: mysterious 10.4% Pin
lw@zi 12-Jul-17 2:39
professional lw@zi 12-Jul-17 2:39 
GeneralRe: CSS fun: mysterious 10.4% Pin
Richard Deeming12-Jul-17 2:46
mveRichard Deeming12-Jul-17 2:46 
GeneralRe: CSS fun: mysterious 10.4% Pin
lw@zi 12-Jul-17 20:00
professional lw@zi 12-Jul-17 20:00 
GeneralRe: CSS fun: mysterious 10.4% Pin
TheGreatAndPowerfulOz17-Jul-17 12:07
MemberTheGreatAndPowerfulOz17-Jul-17 12:07 
GeneralRe: CSS fun: mysterious 10.4% Pin
Jon McKee12-Jul-17 9:11
professionalJon McKee12-Jul-17 9:11 
GeneralRe: CSS fun: mysterious 10.4% Pin
lw@zi 12-Jul-17 20:03
professional lw@zi 12-Jul-17 20:03 
GeneralDoes NULL <> 'string'? Pin
Chris Maunder11-Jul-17 9:38
cofounderChris Maunder11-Jul-17 9:38 
You'd think so. Except in SQL

We had a query:
SQL
Select count(*) 
From TableOne

which returned, say, 500,000 records.

Next we added
SQL
Select count(*) 
From TableOne
Left Join TableTwo On TableTwo.TableTwoID = TableOne.TableTwoID
Where TableTwo.TableTwoID is null or TableTwo.StringColumn <> 'value'

We're trying to find the number of records in TableOne which, when joined with TableTwo, either have no corresponding TableTwo row or the corresponding TableTwo row is not 'value'.

TableTwo.StringColumn is nullable.

The result? Adding the join resulted in 25K records. It should have been over 490K records.

The issue?
SQL
TableTwo.StringColumn <> 'value'

This comparison returns false if TableTwo.StringColumn is null. So one needs to use
SQL
IsNull(TableTwo.StringColumn, '') <> 'value'

to get the correct result.
cheers
Chris Maunder

GeneralRe: Does NULL <> 'string'? Pin
User 1106097911-Jul-17 9:50
MemberUser 1106097911-Jul-17 9:50 
GeneralRe: Does NULL <> 'string'? Pin
Chris Maunder11-Jul-17 9:52
cofounderChris Maunder11-Jul-17 9:52 
GeneralRe: Does NULL <> 'string'? Pin
OriginalGriff11-Jul-17 12:16
mveOriginalGriff11-Jul-17 12:16 
JokeRe: Does NULL <> 'string'? Pin
Nelek12-Jul-17 3:17
protectorNelek12-Jul-17 3:17 
GeneralRe: Does NULL <> 'string'? Pin
Gary Wheeler13-Jul-17 8:01
MemberGary Wheeler13-Jul-17 8:01 
GeneralRe: Does NULL <> 'string'? Pin
Dan Sutton13-Jul-17 5:06
MemberDan Sutton13-Jul-17 5:06 
GeneralRe: Does NULL <> 'string'? Pin
User 1106097913-Jul-17 5:51
MemberUser 1106097913-Jul-17 5:51 
GeneralRe: Does NULL <> 'string'? Pin
Dan Sutton13-Jul-17 9:14
MemberDan Sutton13-Jul-17 9:14 
PraiseRe: Does NULL <> 'string'? Pin
User 1106097913-Jul-17 9:34
MemberUser 1106097913-Jul-17 9:34 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming13-Jul-17 9:08
mveRichard Deeming13-Jul-17 9:08 
GeneralRe: Does NULL <> 'string'? Pin
Dan Sutton13-Jul-17 9:15
MemberDan Sutton13-Jul-17 9:15 
GeneralRe: Does NULL <> 'string'? Pin
Rob Grainger23-Jul-17 0:49
MemberRob Grainger23-Jul-17 0:49 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming11-Jul-17 9:58
mveRichard Deeming11-Jul-17 9:58 
GeneralRe: Does NULL <> 'string'? Pin
Chris Maunder11-Jul-17 10:04
cofounderChris Maunder11-Jul-17 10:04 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming11-Jul-17 10:09
mveRichard Deeming11-Jul-17 10:09 
JokeRe: Does NULL <> 'string'? Pin
User 1106097913-Jul-17 9:45
MemberUser 1106097913-Jul-17 9:45 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming13-Jul-17 10:44
mveRichard Deeming13-Jul-17 10:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.