null

IFNULL is not working

一世执手 提交于 2020-01-13 19:30:28
问题 Hi I am working with mysqli to replace a default value on the table if the data from the database is NULL. I already tried it on PHPmyAdmin and it's working but not on my code :( Here's my SELECT query: $query="SELECT pro_id, pro_name, unit_name, cat_name, IFNULL(quantity,'empty') AS quantity FROM products, unit, categories WHERE products.unit=unit.unit_id AND products.pro_cat=categories.cat_id"; 回答1: If, as one of your comments seems to indicate, the error you're getting is: Incorrect

IFNULL is not working

大城市里の小女人 提交于 2020-01-13 19:30:11
问题 Hi I am working with mysqli to replace a default value on the table if the data from the database is NULL. I already tried it on PHPmyAdmin and it's working but not on my code :( Here's my SELECT query: $query="SELECT pro_id, pro_name, unit_name, cat_name, IFNULL(quantity,'empty') AS quantity FROM products, unit, categories WHERE products.unit=unit.unit_id AND products.pro_cat=categories.cat_id"; 回答1: If, as one of your comments seems to indicate, the error you're getting is: Incorrect

leetcode第二题:两数相加(add two numbers)

你离开我真会死。 提交于 2020-01-13 17:12:00
题目描述 :给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例 : 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807 刷题遇到的问题 :这题在思路上是没有问题的,主要一个坑在指针上。一个结点的next结点为空时, p = p - > next ; //p->next == NULL p = new ListNode ( 0 ) ; 这种情况下会导致链表断开,因为p指向了一个NULL的空间。 以下就是我 错误 的代码: class Solution { ListNode addTwoNumbers ( ListNode l1 , ListNode l2 ) { ListNode head = new ListNode ( 0 ) ; ListNode p = l1 , q = l2 , curr = head ; int carry = 0 ; while ( p != null || q != null ) { int x = ( p != null ) ? p . val : 0 ;

sqlzoo第八关Using Null

谁说胖子不能爱 提交于 2020-01-13 09:12:44
第八关 Using Null 老师和部门数据库 表1 老师表(teacher) id(编号) dept(部门) name(名字) phone(电话) mobile(手机) 101 1 Shrivell 2753 07986 555 1234 102 1 Throd 2754 07122 555 1920 103 1 Splint 2293 … … … … … 表2 部门表(dept) id(编号) name(名字) 1 Computing 2 Design 3 Engineering … … 8.1题目及答案 List the teachers who have NULL for their department. select name from teacher where dept is null Note the INNER JOIN misses the teachers with no department and the departments with no teacher. SELECT teacher . name , dept . name FROM teacher INNER JOIN dept ON ( teacher . dept = dept . id ) Use a different JOIN so that all teachers are

Is it possible to make safe inline Optional in Kotlin?

穿精又带淫゛_ 提交于 2020-01-13 06:39:08
问题 In Kotlin sometimes I have to work with double nullability. For example, I need double nullability, when I want to use T? where T may be a nullable type. There are a few approaches for doing this: Holder<T>? where Holder is data class Holder<out T>(val element: T) - example 1 boolean flag variable - example 1 containsKey for Map<K, T?> - example 1 The special UNINITIALIZED_VALUE for representing the second kind of null - example 1 The last approach has the best performance, but it's also the

spring+springmvc+springjdbc实现读取xls文件并插入到数据库中

谁都会走 提交于 2020-01-13 04:53:21
环境说明:spring+springmvc+springJdbc 数据库为,mysql8.0 1、表字段类型: SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `user` -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `roleId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `username` varchar(255) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `company_name` varchar(255) DEFAULT NULL, `company_code` varchar(255) DEFAULT NULL, `region_code` varchar(255) DEFAULT NULL, `first_cp_code` varchar(255) DEFAULT NULL, `second_cp_code` varchar(255) DEFAULT NULL, `first

Java8之Optional

ぐ巨炮叔叔 提交于 2020-01-12 15:08:11
Optional类是为了避免空指针异常的发生 其中有三种创建Optional实例的方法,我们接下来进行分别介绍 第一种方法 ---- empty (静态方法) 源码: // 静态方法,可以使用类名直接使用。 // 返回一个空的Optional实例。 public static < T > Optional < T > empty ( ) { @SuppressWarnings ( "unchecked" ) Optional < T > t = ( Optional < T > ) EMPTY ; return t ; } 示例代码: Optional < String > optional = Optional . empty ( ) ; 第二种方法 ---- of (静态方法) 源码: // public static < T > Optional < T > of ( T value ) { return new Optional < > ( value ) ; } 示例代码: // 直接定义值,返回一个值不为空的Optional示例 Optional < String > optionalS = Optional . of ( "hello" ) ; 第三种方法 ---- ofNullable(静态方法) 源码: // 根据源码分析,这个方法跟of方法差不多

How are NULLs stored in a database?

半城伤御伤魂 提交于 2020-01-12 14:34:12
问题 I'm curious to know how NULLs are stored into a database ? It surely depends on the database server but I would like to have an general idea about it. First try: Suppose that the server put a undefined value (could be anything) into the field for a NULL value. Could you be very lucky and retrieve the NULL value with ...WHERE field = 'the undefined value (remember, could be anything...)' Second try: Does the server have a flag or any meta-data somewhere to indicate this field is NULL ? Then

How to use FacesContext.getCurrentInstance(), it returns null

為{幸葍}努か 提交于 2020-01-12 14:08:47
问题 I've been struggling for the last couple of days with the login part of my web app. I've gotten to the point where I can succesfully authenticate a user using the JDBCRealm on tomcat(by reading users from a sql server database). Now I want to send some kind of feedback when the user's account has been blocked, or when the credentials are incorrect, this is where I'm stuck now. I wanted to use this: try { request.login(request.getParameter("user"), request.getParameter("pass")); } catch

How to use FacesContext.getCurrentInstance(), it returns null

心不动则不痛 提交于 2020-01-12 14:08:35
问题 I've been struggling for the last couple of days with the login part of my web app. I've gotten to the point where I can succesfully authenticate a user using the JDBCRealm on tomcat(by reading users from a sql server database). Now I want to send some kind of feedback when the user's account has been blocked, or when the credentials are incorrect, this is where I'm stuck now. I wanted to use this: try { request.login(request.getParameter("user"), request.getParameter("pass")); } catch