Checking sqlite datetime NULL with RoR

Posted by Paul N on Stack Overflow See other posts from Stack Overflow or by Paul N
Published on 2010-08-15T19:56:29Z Indexed on 2012/09/22 15:37 UTC
Read the original article Hit count: 155

Filed under:

RoR/SQL newbie here.

My datetime column 'deleted_at' are all uninitialized. Running this query returns an error:

SELECT * FROM variants v
 ON v.id = ovv0.variant_id INNER JOIN option_values_variants ovv1
 ON v.id = ovv1.variant_id INNER JOIN option_values_variants ovv2
 ON v.id = ovv2.variant_id INNER JOIN option_values_variants ovv3
 ON v.id = ovv3.variant_id INNER JOIN option_values_variants ovv4
 ON v.id = ovv4.variant_id
 WHERE v.deleted_at = NULL
 AND v.product_id = 1060500595

However, if I set my datetime values to 0, and set my query to v.deleted_at = 0, the correct variant is returned to me.

How do I check for uninitialized/NULL datetimes?

© Stack Overflow or respective owner

Related posts about sqlite