Thursday, January 26, 2012

SQL Retrieve/Count Record on a previous date

1:  -- a simple demonstration of sql where you can   
2:  -- retrieve a record from a previous date  
3:  select sum(data_gathered) as data_gatherer,   
4:      name from tblctivity  
5:       where name like '%prgGatherer1.xml%'  
6:         and (date(rec_date) = (CURDATE() - 1));  

Tuesday, January 3, 2012

Checking nulls with MySQL

Assuming QuantityPerUnit is the field to be tested.
1:  -- return products with no null values  
2:  select * from products where QuantityPerUnit is not null;  
3:  -- return products with null values  
4:  select * from products where isnull(QuantityPerUnit);