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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:40:01+00:00 2026-06-12T01:40:01+00:00

Is there an opposite but equivalent UNION function for mysql? I know it’s possible

  • 0

Is there an opposite but equivalent UNION function for mysql?

I know it’s possible to do this with a longer query but I’m curious on whether or not there’s a function equivalent.

I have 2 select statements for 2 different tables

select state, state_name, id, idname, phone, mobile, home from table1
select state, state_name, id, idname, phone, mobile, home from table2

And I need a query that pulls only from table1 and ONLY if idname, phone, mobile, home from table1 doesn’t match with table2

For example: Table1 has

AK | Alaska | 1 | row6   | 453  | 567 | 123

but Table 2 has:

AK | Alaska | 1 | row6   | 453  | 567 | 123
AK | Alaska | 1 | row6   | NULL | 567 | 123
AK | Alaska | 1 | tttttt | 453  | 567 | 123

The query will display

AK | Alaska | 1 | row6   | NULL | 567 | 123
AK | Alaska | 1 | tttttt | 453  | 567 | 123

will NOT display

AK | Alaska | 1 | row6   | 453  | 567 | 123
  • 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-12T01:40:02+00:00Added an answer on June 12, 2026 at 1:40 am

    In standard SQL you can use the ANSI SQL EXCEPT operator which is an exact analogue of UNION

    SELECT * FROM Table2
    EXCEPT
    SELECT * FROM Table1
    

    There is also an INTERSECT set operator that would show rows that both sources have in common.

    Unfortunately neither of these are supported in current versions of MySQL so you need to use one of these other 3 more verbose ways of achieving an anti semi join.

    NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any function that do the opposite job of QString::split() . I mean
There are nice SO question and answers about this issue, but these options didn't
I need to know how to find a vector opposite to another, but the
What is the opposite of the Math.tan(double x) function of java? I know that
There are many threads about going the opposite way, but I am interested in
I know solutions exist to get HTML / CSS to PDF, but is there
Is there a opposite operator option for the Listcontains function in coldfusion? I need
This might be the opposite of my previous question here but anyway, I need
I'm sure there is an answer to this somewhere but I'm clearly using the
This might be too little information... but why is this working opposite as 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.