Wouldn't 

SELECT * FROM table1
EXCEPT
SELECT * FROM table2

solve this problem?
I think it does for the example provided. Not sure if it would work in 
real-world environment.


-----Ursprüngliche Nachricht-----
Von: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
Im Auftrag von Stephen Chrzanowski
Gesendet: Montag, 29. Juli 2013 13:01
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] Comparing two tables column by column

To be fair to me, the example had the same column names.  If the two tables 
have the same column names, then having a bit of extra code to tag on the 
column name + "_1" might have worked.  As my first reply answered, untested. ;)


On Mon, Jul 29, 2013 at 6:46 AM, Clemens Ladisch <clem...@ladisch.de> wrote:

> Simon Slavin wrote:
> > On 29 Jul 2013, at 4:03am, Fehmi Noyan ISI <fnoyan...@yahoo.com> wrote:
> >> One point I forgot to mention; the number of columns is unknown.
> >
> > There is no way in SQL to say "Give me the contents of all the 
> > columns
> of a row of table in an unambiguous format.".
>
> Well, just "give me" could be done with "SELECT *", but it is almost 
> impossible to compare such columns in SQL.
>
> If the tables have the same number _and_ names of columns, it would be 
> possible to use a NATURAL JOIN, and combine this with an outer join to 
> get non-matching records:
>
>     SELECT table1.* FROM table1 NATURAL LEFT JOIN table2 WHERE 
> table2.rowid IS NULL
>
> This will return those records from table1 that do not have a matching 
> record in table2.  For the other direction, run the same query with 
> "table1" and "table2" exchanged.
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to