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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:05:34+00:00 2026-06-17T19:05:34+00:00

If I do the following query: select * from tabla where codigo in (33,34,55,10,22,50);

  • 0

If I do the following query:

select * from tabla where codigo in (33,34,55,10,22,50);

msyql shows me the records that match the query.

But what if I want to know what records from this query (33,34,55,10,22,50) which are not in the database?

Is there any way to know that without having to compare one record per one by myself?

Excuse me, I din’t explain it well. This shows me the records which are in the database but don’t match the query. I want to know what of this records (33,34,55,10,22,50) are not in the database.

  • 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-17T19:05:36+00:00Added an answer on June 17, 2026 at 7:05 pm

    Use NOT:

    select * from tabla where codigo NOT in (33,34,55,10,22,50); 
    

    UPDATE

    In light of this new explanation, do this:

    SELECT n.id
    FROM
      (SELECT 33 AS codigo
       UNION SELECT 34
       UNION SELECT 55 
       UNION SELECT 10
       UNION SELECT 22 
       UNION SELECT 50) AS n
    LEFT JOIN tabla USING (codigo)
    WHERE tabla.codigo IS NULL;
    

    Unfortunately, MySQL (and many other systems) don’t give a simple way to use an arbitrary list of numbers that aren’t already in some table. If you need to do this dynamically, I would suggest adding these numbers to a temp table in place of a hard-coded batch of UNIONs. Or generate a reusable numbers table (I find this fairly useful), and use the values from there. For example:

    SELECT nt.id
    FROM numbers_table nt
    LEFT JOIN tabla ON nt.id = tabla.codigo
    WHERE nt.id IN (33,34,55,10,22,50)
      AND tabla.codigo IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute the following query using Subsonic: SELECT MAX([restore_date]) FROM [msdb].[dbo].[restorehistory] While
I want to make one query like this: SELECT * FROM my_table where column_one
I want to get rows from database. I am using the following query: select
I have the following query: SELECT * FROM table_name WHERE (col_1 LIKE '%$keyword%' OR
Can I have a prepared statement with the following query: select * from table
I've seen people writing the following query SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2
Please look the following query: SELECT ID, START, END FROM TABLEA the result is:
I'm using the following query to select users from my 'users' table with the
I am using the following query to select wait times from the table wait_times
Possible Duplicate: Writing an SQL query to SELECT item from the following table I

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.