Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1

    Lightbulb matching two table(s) with the same fields but different contents by sql


    hello all.

    i would like to inquire or ask an assistance how to queries two (2) tables with the same number of fields, as well, the same header (did i say the right word) but has different contents?

    its like table GardenA and GardenB ... the main query i would like to acquire is the column name emailaddress.

    i want to find out if the email addresses in GardenA is not present in GardenB ...

    it just happened that i want to send an email to those email addresses that has not yet been send yet (even once) any messages in both tables.


    hope i can be enlighten ...


    cheers!

  2. #2
    You can try using joins.

    e.g.

    Code:
    SELECT t1.email, t2.email
    FROM table1 t1
    LEFT OUTER JOIN table2 t2
    ON t1.email=t2.email
    loop through the result set and find where t2.email is null.

  3. #3
    unsay database nimo??

    oracle, sql, mysql or what?

  4. #4
    also... why do you have two identical tables? why not have only one table with a flag whether an email address has been notified or not?

  5. #5
    sakto lagi ka bro... hahaha... trabaho naka bro?

  6. #6

    Lightbulb matching two table(s) with the same fields but different contents by sql

    Quote Originally Posted by UtOkbOlinAO View Post
    sakto lagi ka bro... hahaha... trabaho naka bro?

    hello again guys

    thanks to all who have contributed to these inquiry of mine.

    it surely a great of help. cheers!



    p.s. happy weekend also

  7. #7
    A simpler query would be
    "select * from table1 except select * from table2 ".
    This is an assumption that you are using an SQL Server Database. In this case, you can compare one or more fields between two tables.
    But the above code is not that accurate when you are really to find the difference between two tables. It would take a higher step than just using "outer join" or "except" operator. "Left Outer Join" or "except" only checks one direction from Table1 to Table2. How about the differences between Table2 to Table1?
    If you are interested on how to check and compare two tables you may follow this link:SQL Server 2005: Using EXCEPT and INTERSECT to compare tables

  8. #8
    Use subselect:
    select * from gardenA where gardenA.email not in (select email from gardenB)
    union all
    select * from gardenB where gardenB.email not in (select email from gardenA)

  9. #9
    Quote Originally Posted by cold_fusion View Post
    Use subselect:
    select * from gardenA where gardenA.email not in (select email from gardenB)
    union all
    select * from gardenB where gardenB.email not in (select email from gardenA)
    if i were u, id go with this solution..

  10. #10
    Quote Originally Posted by zengatsu View Post
    if i were u, id go with this solution..

    I agree with this solution, safe and fast..

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. Replies: 172
    Last Post: 03-22-2013, 08:56 PM
  2. Canon DSLR, are they the same stuff? but with different names?
    By dhaxkz in forum Gizmos & Gadgets (Old)
    Replies: 7
    Last Post: 01-27-2011, 05:00 PM
  3. Replies: 5
    Last Post: 10-18-2010, 09:46 AM
  4. Replies: 0
    Last Post: 04-22-2010, 01:02 PM
  5. Replies: 0
    Last Post: 03-23-2008, 06:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top