Solved

update in sqlite

Posted on 2008-10-29
6
183 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now