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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:51:32+00:00 2026-06-01T15:51:32+00:00

well i do not know how to use sql union properly . i have

  • 0

well i do not know how to use sql union properly .
i have two tables with domains(url) i want to compare table1 with table2 so that i get unique domain from table 2 which is not in table 1.

example

table1

id   domain
1    google.com
2    facebook
3    stackoverflow.com

table2

id   domain
1    youtube.com
2    facebook
3    stackoverflow.com

so i want that i compare both tables and get youtube.com because its not in table1
i used sql union like that

$query="SELECT table1.domain, table2.domain "."FROM table1, table2 "."WHERE table1.domain != table2.domain";
$result = mysql_query($query) or die(mysql_error());
while ($rec = mysql_fetch_array($result))
{
$new_url=$rec["domain"];
}

now i get double results like youtube.com youtube.com
so help whats wrong with my sql statement

  • 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-01T15:51:34+00:00Added an answer on June 1, 2026 at 3:51 pm

    You should use

    SELECT t2.domain FROM
    table2 t2 LEFT JOIN table1 t1
        ON t2.domain = t1.domain
    WHERE t1.domain IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have these two tables: Invoice ------- iInvoiceID int PK not null dtCompleted
^([0-9]*[1-9][0-9]*(\.[0-9]+)?|[0]+\.[0-9]*[1-9][0-9]*)$ I don't know regular expression well. Above regular expression does not allow input
Suppose i have the code snippet as follows : ( clarification purpose/not well formed
I need to use basic javascript here and I'm not well versed with it.
I use Jquery fadeIn effect, but it does not work well in Chrome (neither
I want to use ms sql 2005 to send email reminders to my customers.
I have two tables: Invoice (ID, InternalPrice, ExternalPrice) InvoiceSummary (InvoiceID, Variance ) In this
I never have used SQL transactions, and in my case I know that I
I have a large vb6/sql database app (hundreds of tables, classes, and forms) that
I'm using embedded SQL with Java. I have a simple table where I want

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.