Questions tagged [isnull]

`ISNULL` is a proprietary SQL function that replaces NULL with the specified replacement value.

ISNULL is a SQL function that replaces NULL with the specified replacement value.

The ANSI/ISO SQL standard function COALESCE serves the same purpose, and is widely implemented.

Reference

MSDN Article

706 questions
163
votes
7 answers

is_null($x) vs $x === null in PHP

Possible Duplicate: What's the difference between is_null($var) and ($var === null)? PHP has two (that I know of, and three if you count isset()) methods to determine if a value is null: is_null() and === null. I have heard, but not confirmed,…
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
123
votes
10 answers

C# equivalent of the IsNull() function in SQL Server

In SQL Server you can use the IsNull() function to check if a value is null, and if it is, return another value. Now I am wondering if there is anything similar in C#. For example, I want to do something like: myNewValue = IsNull(myValue, new…
HAdes
  • 16,713
  • 22
  • 58
  • 74
87
votes
9 answers

Using ISNULL vs using COALESCE for checking a specific condition?

I know that multiple parameters can be passed to COALESCE, but when you want to to check just one expression to see if it doesn't exist, do you use a default or is it a better practice to use ISNULL instead? Is there any performance gain between…
JBone
  • 3,163
  • 11
  • 36
  • 47
64
votes
7 answers

MySQL comparison with null value

I have a column called CODE in a MySQL table which can be NULL. Say I have some rows with CODE='C' which I want to ignore in my select result set. I can have either CODE=NULL or CODE!='C' in my result set. The following query does not return a row…
dev_musings
  • 1,161
  • 1
  • 10
  • 17
60
votes
4 answers

how to check for null with a ng-if values in a view with angularjs?

i have this situation
but test.view== null doesn't work, neither just checking for test.view or test.view == '' any…
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
53
votes
9 answers

Is there a opposite function to ISNULL in sql server? To do Is not null?

I have this code in my select statement ISNULL(a.PolicySignedDateTime,aq.Amount) AS 'Signed Premium', But I want to see if "a.PolicySignedDateTime" is not null. Is there a easy function to do this which does not involve using a "if"…
Bobby
  • 2,830
  • 3
  • 19
  • 36
51
votes
4 answers

Equivalent of SQL ISNULL in LINQ?

In SQL you can run a ISNULL(null,'') how would you do this in a linq query? I have a join in this query: var hht = from x in db.HandheldAssets join a in db.HandheldDevInfos on x.AssetID equals a.DevName into DevInfo from aa in…
MartGriff
  • 2,821
  • 7
  • 38
  • 42
49
votes
5 answers

TSQL ORDER BY with nulls first or last (at bottom or top)

I have a date column which has some NULL. I want to order by the date column ASC, but I need the NULL s to be at the bottom. How to do it on TSQL?
Myurathan Kajendran
  • 647
  • 3
  • 8
  • 15
45
votes
5 answers

Remove rows with empty lists from pandas data frame

I have a data frame with some columns with empty lists and others with lists of strings: donation_orgs donation_context 0 [] [] 1 [the research of Dr. ...] …
Ben Price
  • 677
  • 3
  • 8
  • 16
42
votes
5 answers

jQuery check if Cookie exists, if not create it

I cannot get this code to work I must be missing something pretty simple. I am trying to check to see if a Cookie exists, if it does {do nothing} if it doesn't {create it}. I am testing the cookie by including an alert on a page. Basically I do…
ToddN
  • 2,901
  • 14
  • 56
  • 96
28
votes
2 answers

MySQL - How Do I Count Nulls and Not Nulls?

I have a simple table of installs: prod_code email install_slot If the install_slot is NULL, then it's an available install slot. Not null -- then, used slot. I need to return a result of total installs for a given product and email, as well as a…
Volomike
  • 23,743
  • 21
  • 113
  • 209
27
votes
3 answers

Why is T-SQL ISNULL() truncating the string and COALESCE is not?

Given the following: SELECT ISNULL('XY' + NULL, 'ABCDEFGHIJ') -- Outputs ABC (Why?) SELECT COALESCE('XY' + NULL, 'ABCDEFGHIJ') -- Outputs ABCDEFGHIJ Why are these statements returning different results?
natenho
  • 5,231
  • 4
  • 27
  • 52
27
votes
2 answers

Check if array value isset and is null

How to check if array variable $a = array('a'=>1, 'c'=>null); is set and is null. function check($array, $key) { if (isset($array[$key])) { if (is_null($array[$key])) { echo $key . ' is null'; } echo $key . '…
Bartek Kosa
  • 842
  • 1
  • 14
  • 25
26
votes
2 answers

Django: filtering queryset by 'field__isnull=True' or 'field=None'?

I have to filter a queryset by a dynamic value (which can be None): may I simply write: filtered_queryset = queryset.filter(field=value) or shall I check for None: if value is None: filtered_queryset = queryset.filter(field__isnull=True) else: …
Don
  • 16,928
  • 12
  • 63
  • 101
24
votes
1 answer

Peewee syntax for selecting on null field

I have researched this everywhere and can't seem to find an answer. I hope I haven't duplicated this (as it's my first question on SO). I am trying to write a select query with Peewee that would normally go ... WHERE foo = NULL; in SQL world. MySQL…
thaavik
  • 3,257
  • 2
  • 18
  • 25
1
2 3
47 48