Solved

update in sqlite

Posted on 2008-10-29
6
185 Views
Last Modified: 2012-05-05
I need an sql which works on MS-SQL and sqlite and does this::

update person SET pers_SecTerr = Comp_SecTerr FROM person join company on Pers_CompanyId = Comp_CompanyId WHERE COALESCE(pers_SecTerr,'') <> COALESCE (comp_SecTerr,'');

That works on MSSQL but not on sqlite.
Help?
0
Comment
Question by:prooffice
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:jfmador
ID: 22831981
you cannot use UPDATE ... FROM using SQL Lite

may be give a try to this

update person SET pers_SecTerr = (SELECT Comp_SecTerr FROM company WHERE persone.Pers_CompanyId = company.Comp_CompanyId and COALESCE(pers_SecTerr,'') <> COALESCE (comp_SecTerr,''))

http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSqlUpdateWithFrom
0
 
LVL 5

Accepted Solution

by:
jfmador earned 500 total points
ID: 22831996
Sorry I mistyped one table and forgot to prefix your column...

update person SET pers_SecTerr = (SELECT Comp_SecTerr FROM company WHERE person.Pers_CompanyId = company.Comp_CompanyId and COALESCE(person.pers_SecTerr,'') <> COALESCE (company.comp_SecTerr,''))
0
 
LVL 9

Expert Comment

by:jamesgu
ID: 22832015
update person SET pers_SecTerr = Comp_SecTerr FROM person join company on Pers_CompanyId = Comp_CompanyId and COALESCE(pers_SecTerr,'') <> COALESCE (comp_SecTerr,'');

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 5

Expert Comment

by:jfmador
ID: 22832054
sorry James, SQLite does not support UPDATE .... FROM statement
0
 
LVL 9

Expert Comment

by:jamesgu
ID: 22832114
jfmador's query should work on both databases

0
 

Author Closing Comment

by:prooffice
ID: 31511202
Thanks
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question