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 7864723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:52:11+00:00 2026-06-02T23:52:11+00:00

I have a table called scheduled_sessions and a Boolean column called instructor_performed to check

  • 0

I have a table called scheduled_sessions and a Boolean column called instructor_performed to check if the instructor did teach the class or not.

So I need to find all the records where the instructor didn’t teach the class. But I can’t do this: ScheduledSession.where(:instructor_performed => false) because if the cell is blank, it won’t return that record. I just need all records that are NOT true.

  • 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-06-02T23:52:14+00:00Added an answer on June 2, 2026 at 11:52 pm

    It sounds like your instructor_performed column can be true, false, or NULL, so you need to query for false or NULL, like this:

    ScheduledSession.where(instructor_performed: [false, nil])
    

    You could avoid this complexity if you’d set up your database table to disallow null values in that column. You can specify this constraint when you create the table in a migration:

    add_column :scheduled_session, :instructor_performed, :boolean,
      null: false, default: false
    

    or

    create_table :scheduled_session do |t|
      t.boolean :instructor_performed, null: false, default: false
      ...
    end
    

    Or you can change the constraint for an existing column:

    change_column_null :scheduled_session, :instructor_performed, false, false
    

    In all of the above, we’re setting the column to allow only true or false values, and we’re telling it to use a default value of false. (Without setting the default, you can’t add a no-nulls constraint because your existing data violates it.)

    I almost always disallow nulls when I’m setting up boolean columns (unless I truly want tri-state attributes), because it lets me do this to find everything that’s not true:

    ScheduledSession.where(instructor_performed: false)
    

    Note that other answers (now deleted) that encouraged use of an SQL fragment like "instructor_performed != true" won’t work because SQL won’t let you use = or != to match a NULL value. Kind of weird, but them’s the rules. Instead SQL makes you do this:

    SELECT * from scheduled_sessions WHERE instructor_performed IS NULL
      OR instructor_performed = FALSE;
    

    which the above Rails where query hides from you somewhat, as long as you’re still aware that you’re searching for two values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a table column called status - data type is boolean. i want
I have a table called scheduler_sched which has several columns, including a column called
I have table called Buttons. Buttons table i have column button_number . Table contain
We have a table called table1 ... (c1 int indentity,c2 datetime not null,c3 varchar(50)
I have a table called person, one of the attributes is years_worked. I need
I have table called 'shipped_data' https://i.stack.imgur.com/JXBej.png and need go get all 'caseNumbers' that match
I have table called stats . In am inserting yes or no in the
i have table called as Support, which have a field named Name and contains
I have table called posts in my DB. Each post has field called social_network
I have a table called Stock and another called Listed, within the Stock Table

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.