Subtraction between two tables in SQL

MOHAMED -  
sandul Posted messages 4013 Status Member -
Bonjour,
salamoalaykom. I need a query that gives all the clients that exist in a client table with their spouses who exist in a spouse table. My problem is that single clients do not appear in the result, and I need all clients, even singles.
Configuration: Windows XP Internet Explorer 6.0

3 answers

  1. sandul Posted messages 4013 Status Member 723
     
    Hello,

    It seems that you are making an inner join query. This will return all the common rows (based on the join key) from both tables. If you also want to return rows from the first table that do not have matches (again via the join key used) in the second table, you need to think about using an outer join.

    So look for something like

    Oracle "outer join" sample

    on Google (just replace "Oracle" above with the name of the database you’re interested in) and you will find what you need.

    In a different context, your title is "the subtraction between two SQL tables" which is something else. There are subtraction operators; or queries like
     SELECT bla1, bla2 FROM firstTable WHERE someColumn NOT IN (SELECT anotherColumn FROM secondTable); 


    ++
    6