Deprecated: add_custom_background is deprecated since version 3.4.0! Use add_theme_support( 'custom-background', $args ) instead. in /home/pqmz7qzy9yt5/public_html/wp-includes/functions.php on line 5084

Deprecated: add_custom_image_header is deprecated since version 3.4.0! Use add_theme_support( 'custom-header', $args ) instead. in /home/pqmz7qzy9yt5/public_html/wp-includes/functions.php on line 5084

Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the jquery handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/pqmz7qzy9yt5/public_html/wp-includes/functions.php on line 5536

Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the smoothscroll handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/pqmz7qzy9yt5/public_html/wp-includes/functions.php on line 5536

Deprecated: The called constructor method for WP_Widget in Yoko_SocialLinks_Widget is deprecated since version 4.3.0! Use __construct() instead. in /home/pqmz7qzy9yt5/public_html/wp-includes/functions.php on line 5177
Intro to Databases: SQL Null Values | Megan Taylor

Megan Taylor

front-end dev, volunteacher, news & data junkie, bibliophile, Flyers fan, sci-fi geek and kitteh servant

Intro to Databases: SQL Null Values

Demo: simple college admissions database
College (cName, state, enrollment)
Student (sID, sName, GPA, sizeHS)
Apply (sID, cName, major, decision)

NULL values: undefined or unknown

insert into Student values (432, ‘Kevin’, null, 1500);
insert into Student values (321, ‘Lori’, null, 2500);

find students whose GPA is greater than 3.5
select sID, sName, GPA
from Student
where GPA > 3.5;

NULL values will not show up

find students whose GPA is less than or equal than 3.5
select sID, sName, GPA
from Student
where GPA <= 3.5; NULL values will not show up find students whose GPA is less than or equal to 3.5 or greater than 3.5 select sID, sName, GPA from Student where GPA > 3.5 or GPA <= 3.5; NULL values will not show up select sID, sName, GPA from Student where GPA > 3.5 or GPA <= 3.5 or GPA is null; NULL values will show up find students with GPA > 3.5 or high schools smaller than 1600
select sID, sName, GPA, sizeHS
from Student
where GPA > 3.5 or sizeHS < 1600 or sizeHS>=1600;

students with NULL in GPA still show up

count (distinct xxx) does not count NULLs
distinct will count NULLs

November 5, 2011 | Comments Off on Intro to Databases: SQL Null Values | Categories: Posts | Permalink

Comments are closed.


Notice: Undefined index: host in /home/pqmz7qzy9yt5/public_html/wp-content/plugins/jetpack/modules/stats.php on line 209