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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:26:11+00:00 2026-05-26T13:26:11+00:00

This might be a weird question. Currently, I have a table with a bunch

  • 0

This might be a weird question. Currently, I have a table with a bunch of data in it. Using PHP, I am dynamically creating the IN clause.

SELECT * FROM table
WHERE field IN ('str1', 'str2', [...])

Let’s say no records matched with ‘str1’ or ‘str2’, is there a way to retrieve ‘str1’ and ‘str2’?

  • 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-26T13:26:12+00:00Added an answer on May 26, 2026 at 1:26 pm
    SELECT dmy.id
    FROM (
       SELECT 'str1' as id
       UNION ALL
       SELECT 'str2' 
       UNION ALL
       .....
    ) dmy
    LEFT JOIN some_table ON some_table.field = dmy.id
    WHERE some_table.field IS NULL
    

    On special request, here is an explanation:

    The derived table (the inner select) just creates a “dummy” table that contains all the desired values. Then this dummy table is outer joined to the real table. Anything that has no value (NULL) in the outer joined table (some_table) does not exist in the list of values from the dummy “table”.

    To see the effect of the derived table just run it stand alone without the join:

    SELECT dmy.id
    FROM (
       SELECT 'str1' as id
       UNION ALL
       SELECT 'str2' 
       UNION ALL
       .....
    ) dmy
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seem like a weird question, but bear with me. I'd like to
This might be a weird question, but I'll try anyway. I set up my
this might seem like a weird question, earlier I posted another question on ASP
This might be a weird question. After all, most people want to jump OUT
This might be a weird question. Anyway, I'm working on a jQuery plugin and
I feel this might be a weird/stupid question, but here goes... In the question
This question might be a bit sketchy because I do not have the code
This might be a weird question but I'm trying to figure out why the
This might be a weird question, but I know what I'm looking for i
Hey guys, this question might be a little weird worded but I was looking

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.