Solved

update in sqlite

Posted on 2008-10-29
6
188 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Email Header Detail 12 64
What's wrong with this T-SQL Foreign Key? 7 51
Connection to multiple databases 13 26
Comparison query - 4 columns 9 26
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…

828 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