Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 997699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:04:34+00:00 2026-05-16T07:04:34+00:00

RoR/SQL newbie here. My datetime column ‘ deleted_at ‘ are all uninitialized. Running this

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:04:34+00:00Added an answer on May 16, 2026 at 7:04 am

    Your main error I believe is that ovv0 is not defined. State your inner join, then your clause.

    SELECT * FROM variants v 
    INNER JOIN option_values_variants ovv0 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 = 106050059;
    

    I’d also like us to explore why you are using so many inner joins on the same table. What are you trying to accomplish?

    EDIT:

    For nulls, SQLite is tricky, and considers null to be a type. There is also no true datetime type either. You can verify the column type with the typeof function, which returns a string.

    SELECT * FROM variants v 
    ...
    WHERE typeof(v.deleted_at) = 'null' AND v.product_id = 106050059;
    

    REEDIT:

    There’s also ifnull. That function replaces a null with whatever value you would like. So in your case, with the single command you can check natural 0’s and nulls in one shot. If you’d rather not have natural 0’s and just the nulls, use some other value that should not be a date (say -1) and evaluate against it.

    SELECT * FROM variants v 
    ...
    WHERE ifnull(v.deleted_at,0) = 0 AND v.product_id = 106050059;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code runs on my local RoR/Windows 7 (64-bit): sql = ActiveRecord::Base.connection() last_pk =
I have this RoR app that calls to RAILS_ROOT. When running it using rails
I'm new to this RoR world, I've many SELECT sql queries in my RoR
I am a newbie RoR developer. I am stuck in one problem. I am
i am new to RoR and I am a little confused on this topic.
I'm using RoR + acts_as_solr to query a Solr database. I'm used to using
I'm using Netbeans to develop my RoR project so it is managing the SQL
I have the following call in my RoR script: Foo.where(event = 'Login').group('user_id').order('user_id ASC').count() This
Is there a way to run a query in RoR that would have the
Guys I'm really novice to this RoR, and at this moment i reached to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.