Click here to Skip to main content
15,887,027 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 19:03
professionalV.29-Aug-17 19:03 
GeneralCSS fun: mysterious 10.4% Pin
dan!sh 12-Jul-17 1:39
professional dan!sh 12-Jul-17 1:39 
GeneralRe: CSS fun: mysterious 10.4% PinPopular
Richard Deeming12-Jul-17 1:46
mveRichard Deeming12-Jul-17 1:46 
GeneralRe: CSS fun: mysterious 10.4% Pin
dan!sh 12-Jul-17 19:00
professional dan!sh 12-Jul-17 19:00 
GeneralRe: CSS fun: mysterious 10.4% Pin
TheGreatAndPowerfulOz17-Jul-17 11:07
TheGreatAndPowerfulOz17-Jul-17 11:07 
GeneralRe: CSS fun: mysterious 10.4% Pin
Jon McKee12-Jul-17 8:11
professionalJon McKee12-Jul-17 8:11 
GeneralRe: CSS fun: mysterious 10.4% Pin
dan!sh 12-Jul-17 19:03
professional dan!sh 12-Jul-17 19:03 
GeneralDoes NULL <> 'string'? Pin
Chris Maunder11-Jul-17 8:38
cofounderChris Maunder11-Jul-17 8: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 8:50
User 1106097911-Jul-17 8:50 
GeneralRe: Does NULL <> 'string'? Pin
Chris Maunder11-Jul-17 8:52
cofounderChris Maunder11-Jul-17 8:52 
GeneralRe: Does NULL <> 'string'? Pin
OriginalGriff11-Jul-17 11:16
mveOriginalGriff11-Jul-17 11:16 
JokeRe: Does NULL <> 'string'? Pin
Nelek12-Jul-17 2:17
protectorNelek12-Jul-17 2:17 
GeneralRe: Does NULL <> 'string'? Pin
Gary Wheeler13-Jul-17 7:01
Gary Wheeler13-Jul-17 7:01 
GeneralRe: Does NULL <> 'string'? Pin
Dan Sutton13-Jul-17 4:06
Dan Sutton13-Jul-17 4:06 
GeneralRe: Does NULL <> 'string'? Pin
User 1106097913-Jul-17 4:51
User 1106097913-Jul-17 4:51 
GeneralRe: Does NULL <> 'string'? Pin
Dan Sutton13-Jul-17 8:14
Dan Sutton13-Jul-17 8:14 
PraiseRe: Does NULL <> 'string'? Pin
User 1106097913-Jul-17 8:34
User 1106097913-Jul-17 8:34 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming13-Jul-17 8:08
mveRichard Deeming13-Jul-17 8:08 
GeneralRe: Does NULL <> 'string'? Pin
Dan Sutton13-Jul-17 8:15
Dan Sutton13-Jul-17 8:15 
GeneralRe: Does NULL <> 'string'? Pin
Rob Grainger22-Jul-17 23:49
Rob Grainger22-Jul-17 23:49 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming11-Jul-17 8:58
mveRichard Deeming11-Jul-17 8:58 
GeneralRe: Does NULL <> 'string'? Pin
Chris Maunder11-Jul-17 9:04
cofounderChris Maunder11-Jul-17 9:04 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming11-Jul-17 9:09
mveRichard Deeming11-Jul-17 9:09 
JokeRe: Does NULL <> 'string'? Pin
User 1106097913-Jul-17 8:45
User 1106097913-Jul-17 8:45 
GeneralRe: Does NULL <> 'string'? Pin
Richard Deeming13-Jul-17 9:44
mveRichard Deeming13-Jul-17 9: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.