isnull

Include null results in group_concat

帅比萌擦擦* 提交于 2019-12-20 03:37:13
问题 I have two tables like this profile_answers +---------+------------+ | id | class_name | +---------+------------+ | 1 | Class 1 | | 2 | Class 2 | | 3 | Class 1 | +---------+------------+ educations +---------+--------------------+------------+ | id | profile_answers_id | sample | +---------+--------------------+------------+ | 1 | 1 | 1234 | | 2 | 1 | 2334 | | 3 | 1 | 3434 | +---------+------------+--------------------+ I ran the query, select educations.profile_answer_id, GROUP_CONCAT

MySQL comparison with null value

寵の児 提交于 2019-12-17 07:29:09
问题 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 with CODE as NULL: SELECT * from TABLE where CODE!='C' But this query works as expected and I know it is the right way to do it. SELECT * from TABLE where CODE IS NULL OR CODE!='C' My question is why does having only CODE!='C' does not return rows

How to remove space from SQL

旧时模样 提交于 2019-12-12 06:28:51
问题 Example col1 col 2 col3 300 Broad ST ,(IsNUll((Cast(FLOOR(col1) as CHAR (7) )),'') + ' ' + IsNull(col2,'') + ' ' + isnull(col3,'')) as col4 result i get is 300 Broad ST what i want is 300 Broad St. there is 4 or 5 space between 300 and Broad the data type for col1 is numeric and for col 2 and 3 is nvarchar. I don't want to change the data type. 回答1: This looks a lot like SQL Server. If so: stuff(coalesce(' ' + Cast(floor(col1) as varchar(7)), '') + coalesce(' ' + col2, '') + coalesce(' ' +

Fastest way to find not null filed in sqlite

匆匆过客 提交于 2019-12-12 01:38:48
问题 I have sqlite table CREATE TABLE IF NOT EXISTS [app_status]( [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , [status] TEXT DEFAULT NULL ) This table is having multiple records like 1 "success" 2 NULL where NULL is sqlite NULL What is the fastest way to find out if table at-least one row where status IS NOT NULL ? Can I create some index or something else which I can use to count Not NULL fields ? I have written following query SELECT 1 \ FROM [app_status]\ WHERE [status] IS NOT NULL But it

SQL: ISNULL function with different type of parameters

﹥>﹥吖頭↗ 提交于 2019-12-11 10:46:21
问题 In SQL Server, ISNULL() function has to same type of parameters. check_expression Is the expression to be checked for NULL. check_expression can be of any type. replacement_value Is the expression to be returned if check_expression is NULL. replacement_value must have the same type as check_expresssion . How can I use it with different type of parameter? I want to use with date and string parameter like this ISNULL(A.DATE, '-') NOTE : Type of A.DATE is datetime . EDIT-1 : My full query which

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

不问归期 提交于 2019-12-11 03:57:38
问题 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) { if(obj.computers != 'undefined' && obj.computers != null)) { ..... As you can see, if I need to see if obj.computers.favorite has been set, I have to really nest some conditional logic there. Some of our objects go 3, 4, 5 levels deep. This is what I would like to be

What is the best way to extend null check?

空扰寡人 提交于 2019-12-09 04:20:16
问题 You all do this: public void Proc(object parameter) { if (parameter == null) throw new ArgumentNullException("parameter"); // Main code. } Jon Skeet once mentioned that he sometimes uses the extension to do this check so you can do just: parameter.ThrowIfNull("parameter"); So I come of with two implementations of this extension and I don't know which one is the best. First: internal static void ThrowIfNull<T>(this T o, string paramName) where T : class { if (o == null) throw new

Is Sql Server's ISNULL() function lazy/short-circuited?

独自空忆成欢 提交于 2019-12-08 17:03:54
问题 TIs ISNULL() a lazy function? That is, if i code something like the following: SELECT ISNULL(MYFIELD, getMyFunction()) FROM MYTABLE will it always evaluate getMyFunction() or will it only evaluate it in the case where MYFIELD is actually null? 回答1: It's whichever it thinks will work best. Now it's functionally lazy, which is the important thing. E.g. if col1 is a varchar which will always contain a number when col2 is null, then isnull(col2, cast(col1 as int)) Will work. However, it's not

IS NOT NULL and ISNULL( str, NULL ) in WHERE clause

橙三吉。 提交于 2019-12-07 15:00:27
问题 I have three tables (simplified here): recipients: recipientId, isGroup users: userId, first name, last name groups: groupid, groupname I want to retreive the first name / last name if the recipient is a user, and the group name if the recipient is a group. It's possible that the recipient is neither (i.e. a group that was deleted/no longer exists), so in that case I want to return nothing. So this is what I did: select u.first_name, u.last_name, g.groupname, r.isGroup from recipients r left

Convert INT column values to an empty string using ISNULL

二次信任 提交于 2019-12-07 10:03:55
问题 I need to convert column ID of INT data type to a empty string ['']. I should not modify the source column data type, but need to convert it in my transformation in the other table. The ID column is "nullable" as it has null in it.This is my code. CREATE TABLE #V(ID INT) ; INSERT INTO #V VALUES (1),(2),(3),(4),(5),(NULL),(NULL) ; SELECT CASE WHEN CAST(ISNULL(ID,'') AS VARCHAR(10)) = '' THEN '' ELSE ID END AS ID_Column FROM #V; this returns: ID_Column 1 2 3 4 5 NULL NULL when I modify my CASE