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
3
votes
1 answer

How does Hibernate function Restrictions.allEq(Map) treat null values?

I'm wondering how the Hibernate function Restrictions.allEq(Map ...) treats null values inside input Map (if as multiple Restrictions.eq(String, Object) or Restrictions.eqOrIsNull(String, Object)) or whatelse). After a quick search…
mginius
  • 104
  • 2
  • 12
3
votes
4 answers

What's the difference between "is null " AND "<=> NULL"

What's the difference between is null and <=> NULL ? mysql> SELECT * FROM param WHERE num is null; +-----+------+ | id | num | +-----+------+ | 8 | NULL | | 225 | NULL | +-----+------+ 2 rows in set (0.00 sec) mysql> SELECT * FROM param WHERE…
Michael Phelps
  • 3,451
  • 7
  • 36
  • 64
3
votes
6 answers

Replace null value with default text

I know this question has been asked many times, but I have the following piece of code that I am trying to use to default null values. Can someone please help me. I tried this code but instead of giving me "NO DATA" for the null values, it doesnt…
rvphx
  • 2,324
  • 6
  • 40
  • 69
3
votes
2 answers

How to show "0" as default instead of "Null" in sql select query

I want to get 0 instead of null in my select query. I mean currently my query is showing NULL for amount column if there are no entry in table. Can I get 0 for amount column in select query if it has NULL?
AnandMeena
  • 528
  • 3
  • 11
  • 26
3
votes
2 answers

remove trailing chars to get numeric value

I'm struggling to combine two expression into one so that I can remove trailing 'mm' chars of a varchar column which holds values like 3.214mm and use those chars as numeric values. The problem I have is that there can be also null or empty string…
Tony Clifton
  • 703
  • 3
  • 14
  • 27
3
votes
2 answers

NHibernate equivalent of SQL IsNull(column, 'defaultValue')

How can I use NHibernate (preferably QueryOver syntax) to get the following SQL SELECT this_.Name as_, count(IsNull(this_.Name , 'UNKNOWN') ) as NameCount FROM...
getit
  • 623
  • 2
  • 8
  • 30
3
votes
2 answers

SQLITE (fmdb) select where x is null not working

I'm using FMDB on iOS, attempting to query a table with a statement such as, select * from test where foo isNull In the sqlite C API, this ends up binding to null using this API, int sqlite3_bind_null(sqlite3_stmt*, int); This isn't working. The…
David
  • 2,770
  • 5
  • 35
  • 43
3
votes
0 answers

.? operator theoretically possible in java?

I know Java doesn't support operator overloading, but it seems there are a few operators in other languages that could potentially benefit Java. Probably my favorite example is the .? operator. Members of an object are only accessed using .? if…
Indigenuity
  • 9,332
  • 6
  • 39
  • 68
3
votes
7 answers

How do I traverse a JavaScript object and check for nulls?

Let's say I have a JavaScript object like: var obj = {}; obj.computers = {}; obj.computers.favorite = "Commodore 64"; obj.computers.popular = "Apple"; Now, I can easily check for null like: if(obj != 'undefined' && obj != null) { …
cbmeeks
  • 11,248
  • 22
  • 85
  • 136
2
votes
2 answers

WHERE clause is not filtering in logical order

I'm writing a general search Stored Procedure to search in a table based on many filters which user can select in the UI (using MS-SQL 2008). Here is ther simplified version: CREATE PROCEDURE SearchAll @FirstName NVARCHAR(MAX) = NULL, …
Amir Pournasserian
  • 1,600
  • 5
  • 22
  • 46
2
votes
3 answers

Difference between NOT NULL constraint and CHECK(attr is not null)

I wanted to create an outline constraint for an alter key(NOT NULL + UNIQUE), but I think the NOT NULL constraint can't be placed outline, therefore, I think I have to options: Outline constraint: CHECK(attr IS NOT NULL) In-line constraint NOT NULL…
Mario Corchero
  • 5,257
  • 5
  • 33
  • 59
2
votes
1 answer

MySQL LEFT JOIN and IS NULL

i have a query that goes like this: SELECT * FROM table_a LEFT JOIN table_b ON table_a.id_a = table_b.id_a WHERE table_b.field = 'something' OR table_b.field IS NULL i want to have the records with table_b.field = 'something' or the ones where…
Jarry
  • 1,891
  • 3
  • 15
  • 27
2
votes
3 answers

ISNULL : Enhancing Performance?

My query is running s-l-o-w. I'm evaluating my indexes and rebuilding them, but can someone tell me if an index on MyField would be used in this query? SELECT ISNULL(MyField , 'No Data') FROM MyTable My thinking is: When SQL tests fields in…
Scott
  • 95
  • 5
2
votes
2 answers

Error converting data type varchar to float - ISNULL related

Note: I read similar threads on SO but was of no help in this query. I have reproduced the following code where is similar to my real problem. I have to use this syntax because it is already been used in the database, unless there is a convincing…
TheTechGuy
  • 16,560
  • 16
  • 115
  • 136
2
votes
3 answers

Checking MySQL NULL values with PHP

This is how my table looks like.. id col1 col2 --------------- 1 a x 2 NULL y 3 NULL z 4 NULL t col1 has a default value of NULL. I want to use col1 data If col1 is not null, otherwise use col2 data. function something($col1,$col2) { …
tuze
  • 1,978
  • 2
  • 15
  • 19