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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:33:06+00:00 2026-06-07T16:33:06+00:00

I have a load of code in place to ‘filter’ some records based on

  • 0

I have a load of code in place to ‘filter’ some records based on if a certain field appears in a list.

Currently SELCT * FROM table1 ... AND value IN (8, 6, 4, 2, 9, 1, 3, 5, 7) ...

With table1 structure :

CREATE TABLE IF NOT EXISTS `table1` (
    `uniqueid` varchar(32) NOT NULL,
    `value` int(11) DEFAULT NULL,
    ...
    PRIMARY KEY (`uniqueid`)
)

Now I have to store value in a separate table and there may well be more than one ‘value’ in the table.

New table1 structure:

CREATE TABLE IF NOT EXISTS `table1` (
    `uniqueid` varchar(32) NOT NULL,
    ...
    PRIMARY KEY (`uniqueid`)
)

New table2 structure

CREATE TABLE IF NOT EXISTS `table2` (
    `id` int(11) NOT NULL,
    `uniqueid` varchar(32) NOT NULL,
    `value` int(11) DEFAULT NULL,
    ...
    PRIMARY KEY (`id`)
)

You get the idea!

My question is how to check if any record in table2 for uniqueid is in the list given in the first example.

I considered using some sort of COUNT subquery but I’m not sure. I tried:

SELECT * FROM table1, table2 
            WHERE table1.uniqueid = table2.uniqueid 
            AND (SELECT COUNT(id) FROM table1, table2 
                       WHERE table2.uniqueid = table1.uniqueid ) > 0 
            AND table2.value IN (8, 6, ...

But it wasnt working and I don’t really like the approach, feels very messy.

Any help appreciated.

  • 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-07T16:33:08+00:00Added an answer on June 7, 2026 at 4:33 pm

    If you wanted to find those values that exist in 2 tables, implement an INNER JOIN.

       SELECT UniqueID
       FROM Table1 t1
       INNER JOIN Table2 t2 
         ON t1.UniqueID = t2.UniqueID
       WHERE (YourCritiera);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some lisp initialisation code: (eval-when (:compile-toplevel :load-toplevel :execute) (require 'asdf)) (eval-when (:compile-toplevel
I currently have this code in the page/div when you load it without anything
I have this code to load icon and application name , but it is
I have a piece of code that load a very big image in memory.
i have this simple code to load data from other php page using get
I have code that dynamically load 10 different textfields in viewdidload method now if
i have the following code to try and load a local html page in
I have existing code with their own makefiles which I want to load into
I have got this code: XDocument xdoc = XDocument.Load(URI); XElement root = xdoc.Element(forecast); //get
I have the following code - it is used to load a drop down

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.