Solved

update in sqlite

Posted on 2008-10-29
6
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

689 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