On 30 Sep 2009, at 9:55pm, Joe Bennett wrote:

> Find the first row of data in TableB, take Column1 and Column2's data
> from row one and see if that data exists in TableA. Something like
> this: SELECT * FROM TableA WHERE Column1=Row1Data AND
> Column2=Row1Data.

That's a JOIN.  There are lots of types of them but all you need is a  
simple and easy kind.

> When the corresponding data is returned from TableA, I then want to
> check each column in the returned row from TableA matches its
> cooresponding column/ row in TableB... If there is not a match, let me
> know... Then move on to the next row in TableB and do it all over
> again....
>
> I'm attempting to do this in Python and am wondering if it would be
> easier to do this with a query or bring each row in as a dictionary
> and compare...???

Probably not.  Write the obvious thing in Python and just use it: one  
SELECT with a JOIN, and then some code to check every row returned.

It would be technically possible to write some clever SQL to do it all  
in one operation.  But it would be complicated to debug and ... well,  
do you really want to waste the time getting it right ?  And also make  
it difficult for anyone (including you) who has to modify your code  
later ?  Does your application currently run slowly enough to cause a  
problem ?

You have one procedural language (Python) and on declarative one  
(SQL).  I think it's safe to do part of your task in a procedural  
manner.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to