null

IS NULL versus <> 1 SQL bit

余生颓废 提交于 2019-12-19 05:13:27
问题 I have a bit column on a table in a SQL Server 2012 database. I am trying to retrieve all the rows where this bit column is either NULL or NOT TRUE. This query does not bring back what it should: (returns 0 rows) Select * from table where bit_column_value <> 1 This query brings back the correct rows: Select * from table where bit_column_value IS NULL Now, I'd be happy to use the second query, but my issue is that, in a similar query for another table, the reverse of the above is true, where

Best method of assigning NULL value to SqlParameter

不羁的心 提交于 2019-12-19 05:11:12
问题 I have a number of optional input parameters I am using in a C# class method. Since the optional syntax creates a value of '0' when the parameter is not used, the SQL insert command I call in the method winds up inserting as such. However, I need the command to insert a NULL value instead of a 0 when the parameter is not being used. What is the best way to accomplish this without using a large amount of 'if' statements? Below is the code I am referring to. Is there syntax/a command of some

Is NULL defined as nullptr in C++11?

懵懂的女人 提交于 2019-12-19 05:06:59
问题 Will C++11 implementations define NULL as nullptr ? Would this be prescribed by the new C++ standard? 回答1: From the horse's mouth C.3.2.4 Macro NULL [diff.null] 1/ The macro NULL, defined in any of <clocale> , <cstddef> , <cstdio> , <cstdlib> , <cstring> , <ctime> , or <cwchar> , is an implementation-defined C++ null pointer constant in this International Standard (18.2). It is up to each implementation to provide its own definition, gcc if I recall correctly defines it to __nullptr for which

How to compare different values in sql server

旧街凉风 提交于 2019-12-19 04:52:44
问题 I must to check if two values, X and Y are different. If both are null, they must be considered as equal. The unique way I found is: select 1 as valueExists where (@X is null and @Y is not null) or (@Y is null and @X is not null) or (@X <> @Y) Is there a smart way to write this expression? Thanks! 回答1: You can use ISNULL WHERE ISNULL(@X,'') <> ISNULL(@Y,'') 回答2: I think you could use COALESCE for that WHERE coalesce(@X, '') <> coalesce(@Y, '') What it does it returns an empty string if one of

How to compare different values in sql server

不羁岁月 提交于 2019-12-19 04:51:13
问题 I must to check if two values, X and Y are different. If both are null, they must be considered as equal. The unique way I found is: select 1 as valueExists where (@X is null and @Y is not null) or (@Y is null and @X is not null) or (@X <> @Y) Is there a smart way to write this expression? Thanks! 回答1: You can use ISNULL WHERE ISNULL(@X,'') <> ISNULL(@Y,'') 回答2: I think you could use COALESCE for that WHERE coalesce(@X, '') <> coalesce(@Y, '') What it does it returns an empty string if one of

when preparing for segue array contains no data (using swift)

回眸只為那壹抹淺笑 提交于 2019-12-19 04:44:10
问题 Depending on what button is pressed I want to append a list of words to variable (pickedList) declared at the start. When I come to prepare for segue it overwrites what has been added and only using empty array that was added at the start. I am able to append items within the prepare for segue bit and these transfer over but this is not what I want. I am very very new to programming and have searched about a lot but can't seem to find what I am looking for. Thanks in advance! Code looks like

Ruby on Rails: params is nil. undefined method `[]' for nil:NilClass

被刻印的时光 ゝ 提交于 2019-12-19 04:23:50
问题 I am getting an error when trying to access a search page I have made. The problem seems to be that I am trying to remove blanks when there aren't any there. My search function works, but I am having trouble handling the case when technols is nil. Here is my error: NoMethodError in ProjectsController#search undefined method `[]' for nil:NilClass in my project controller, line 26: tech_ids = params["technols"]["id"].reject(&:blank?). Here is my search action: def search tech_ids = params[

Is this the correct syntax for SQLite for making nulls appear last?

浪尽此生 提交于 2019-12-19 04:07:22
问题 select * from table1 order by case Language when null then 1 else 0 end, Language No matter which way I play around with it, it always displays null values first. Is there a standard way to allow non null values to take ordering precedence? Thanks guys 回答1: You don't need WHEN : SELECT * FROM table1 ORDER BY Language IS NULL, Language Operator IS will return 1 on true, 0 otherwise (Operators). EDIT: Dealing with empty TEXT , also: SELECT * FROM table1 ORDER BY Language IS NULL OR Language='',

Why can't my Java method change a passed variable? [duplicate]

谁说我不能喝 提交于 2019-12-19 02:28:09
问题 This question already has answers here : Is Java “pass-by-reference” or “pass-by-value”? (86 answers) Closed last year . I was kind of baffled when I saw the following code did not work as expected. I thought Java always passed variables by references into functions. Therefore, why can't the function reassign the variable? public static void main(String[] args) { String nullTest = null; setNotNull(nullTest); System.out.println(nullTest); } private static void setNotNull(String s) { s = "not

3-链表篇(3)

北城余情 提交于 2019-12-19 02:12:19
附1:Stack API 附2:ArrayList API 题一:输入一个链表,按链表从尾到头的顺序返回一个ArrayList。 法一:递归 1 /** 2 * public class ListNode { 3 * int val; 4 * ListNode next = null; 5 * 6 * ListNode(int val) { 7 * this.val = val; 8 * } 9 * } 10 * 11 */ 12 import java.util.ArrayList; 13 public class Solution { 14 ArrayList list = new ArrayList(); 15 public ArrayList<Integer> printListFromTailToHead(ListNode listNode) { 16 if(listNode!=null){ 17 printListFromTailToHead(listNode.next); 18 list.add(listNode.val); 19 } 20 return list; 21 } 22 } 法二:Stack 1 import java.util.*; 2 public class Solution { 3 ArrayList list = new ArrayList();