Re: [sqlite] to table update

2012-08-23 Thread Igor Tandetnik
yanhong.ye  wrote:
> update tb1 set col1=(select col1 from tb2 ) where tb1.co2=tb2.co2;

The closing parenthesis is in the wrong place:

update tb1 set col1=(select col1 from tb2 where tb1.co2=tb2.co2);

-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] to table update

2012-08-23 Thread Rob Richardson
Are you certain there exist rows in tb1 and tb2 that satisfy the condition?  
What happens when you try?  Is any error message or number returned?  Can you 
run the same query inside an SQLite management tool like SQLite Spy?  Does it 
work there?  Please provide us ALL of the relevant information when you post.

But in this case, it's fairly easy.  (Easy enough for me to get it right?  
We'll see.)  The subquery is returning more than one value.  That's illegal.  
And I hope you mean to update every single row in tb1, because that's what your 
query will do.

And your main query references tb2 without defining it.

RobR

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of yanhong.ye
Sent: Thursday, August 23, 2012 7:32 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] to table update

update tb1 set col1=(select col1 from tb2 ) where tb1.co2=tb2.co2;

it couldn't work

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] to table update

2012-08-23 Thread yanhong.ye
update tb1 set col1=(select col1 from tb2 ) where tb1.co2=tb2.co2;

it couldn't work

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] two table update question

2012-05-08 Thread Simon Slavin

On 9 May 2012, at 2:20am, YAN HONG YE  wrote:

> alter table myref add stkcode varchar(30);
> update myref set stkcode = dzhhq.stkcode;
> 
> this sql command couldn't run in my sqlite.

It does not know which row from the table dzhhq it is meant to use.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] two table update question

2012-05-08 Thread YAN HONG YE
alter table myref add stkcode varchar(30);
update myref set stkcode = dzhhq.stkcode;

this sql command couldn't run in my sqlite.
 

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users