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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:25:52+00:00 2026-05-16T03:25:52+00:00

I have two MySQL tables with a similar structure. i.e. Table_A – Col1, Col2,

  • 0

I have two MySQL tables with a similar structure. i.e.

Table_A - Col1, Col2, Col3, Col4, Col5

Table_B - Col1, Col2, Col3

I need to run a query that says something like:

SELECT * FROM Table_A WHERE (Table_A.Col1 DOES NOT EXISTS in Table_B.Col3 AND Table_B.Col2 = 'A') AND Table_A.Col5 = 2 etc...

So basically I need to select everything from A that isn’t in B where B has extra conditions.

Hopefully the following example will help:

Table_A example rows

1, 5, 'Orange', 'Elephant', 1
2, 3, 'Red', 'Horse', 2
3, 4, 'Blue', 'Rhino', 2
4, 4, 'Pink', 'Cat', 2
5, 2, 'Purple', 'Dog', 2

Table_B example rows

1, 'A', 3
2, 'A', 2
3, 'B', 2
4, 'C', 3

The returned data I need is – I’m querying for all rows from Table_A that (aren’t in Table_B AND Table_B.Col2 = ‘A’) AND Table_A.col5 = 2

4, 4, 'Pink', 'Cat', 2
5, 2, 'Purple', 'Dog', 2

Any ideas?
Thanks!

  • 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-16T03:25:53+00:00Added an answer on May 16, 2026 at 3:25 am
    SELECT A.* FROM table_A AS A
    LEFT JOIN Table_B AS B ON A.Col1 = B.Col3
    WHERE B.Col3 IS NULL AND B.Col2 = 'A' AND ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two mysql tables which are linked together and i need to show
I have a mysql problem. I have two tables like this that I need
I have two mysql tables, one containing details on cars and one containing all
I have two identical tables and need to copy rows from table to another.
I have two MySQL tables, locations and items: locations `id` `name` `address` `latitude` `longitude`
I have two mysql tables which both have a typeID in common. I am
Ok, I have two MYSQL tables: CREATE TABLE `sessions` ( `id` int(11) NOT NULL
that´s my first question in stackoverflow . I have two MYSQL tables: categories and
When I have two mysql servers that have different jobs (holding different databases) but
Say I have an MSSQL table with two columns: an int ID column that's

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.