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

  • SEARCH
  • Home
  • 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 8674161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:38:24+00:00 2026-06-12T19:38:24+00:00

I am quite new to SQL and this is rather a complex command :

  • 0

I am quite new to SQL and this is rather a complex command :

SELECT users.name, 
       from_unixtime(activity.time_stamp, "%D %b %Y  %l:%i:%S"), 
      activity.activity, 
      activity.rfid_tag, 
      chemicals.description 
FROM activity 
JOIN chemicals ON chemicals.bar_code = activity.bar_code 
JOIN users ON users.badge_number=activity.badge_number 
WHERE  (activity="login") 
    OR (activity="logout") 
   OR (activity LIKE "Admin:%") 
   OR (activity="tag") 
   OR (activity="untag") 
   OR (activity LIKE "check out%") 
   OR (activity LIKE "pour%") 
   OR (activity="check out (unscheduled)") 
   OR (activity="not poured after checking out") 
   OR (activity LIKE "invalid:%") 
ORDER BY time_stamp DESC

When I run it, it returns only the rows which match the last OR of the WHERE (723 from 867). For instance, I do not see any rows where activity="login", but SELECT * FROM activity WHERE activity="login" does return some rows.

What am I doing wrong? (and if that should be "INNER JOIN")?

Update

I should have said this was working (with the complex WHERE) before I added the Join (and I am a total SQL beginner).

  • 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-12T19:38:25+00:00Added an answer on June 12, 2026 at 7:38 pm

    Please study the difference between INNER JOIN and LEFT JOIN.

    From looking at your query and crystal ball-gazing based on the names and correlating to real world entities, here’s what I can see:

    When your activity is “pour”, it may involve some chemical, which will join successfully on barcode. When it is “login”, I doubt you’ll get a successful (INNER) JOIN against the chemical table. As someone has mentioned, you really want to turn them into LEFT JOINs, e.g.

    SELECT users.name, 
           from_unixtime(activity.time_stamp, "%D %b %Y  %l:%i:%S"), 
          activity.activity, 
          activity.rfid_tag, 
          chemicals.description 
    FROM activity 
    LEFT JOIN chemicals ON chemicals.bar_code = activity.bar_code 
    LEFT JOIN users ON users.badge_number=activity.badge_number 
    WHERE  (activity="login") 
       OR (activity="logout") 
       OR (activity LIKE "Admin:%") 
       OR (activity="tag") 
       OR (activity="untag") 
       OR (activity LIKE "check out%") 
       OR (activity LIKE "pour%") 
       OR (activity="check out (unscheduled)") 
       OR (activity="not poured after checking out") 
       OR (activity LIKE "invalid:%") 
    ORDER BY time_stamp DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to sql and I'm having trouble writing this i have a
Quite new to this but i have created a SQL script that groups by
I'm quite new in SQl This is my requirement. TableA operation route measurement A
I have this: var blockRegEx = new Regex((proc sql;)(.*?)(quit;), RegexOptions.IgnoreCase | RegexOptions.Multiline); but it
I'm quite new to PL/SQL, and am using Oracle SQL Developer to write a
Iam quite new to functions in SQL and I would like to create a
I am quite new with Linq to SQL and MVC but I follow the
How do I prevent SQL injection when it comes to ColdFusion? I'm quite new
I'm fairly new to SQL, but trying to write quite a complicated query, but
I'm quite new to MDX and im having some trouble getting the following t-sql

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.