On Mon, Feb 23, 2009 at 5:34 PM, Greg Robertson <trifus...@gmail.com> wrote:
> I have two tables each with two fields:
>
> TableA: Field1, Field2
>
> TableB: Field3, Field4
>
>
> I would like to set Field2 in TableA to the value in Field4 in TableB
> where TableA.Field3=TableB.Field4
>
> Sounds simple enough but I can't figure out how to write the UPDATE
> SQLite for this.

You probably meant TableA.Field1

Here is one way

UPDATE TableA
SET Field2 = (SELECT Field4 FROM TableB WHERE Field3 = TableA.Field1)
WHERE EXISTS (SELECT Field4 FROM TableB WHERE Field3 = TableA.Field);


>
> Can someone help?
>
> Thanks
>
> Greg
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Puneet Kishor http://www.punkish.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to