You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Priyanka Karnawat <pr...@sungraceinfotech.co.in> on 2009/08/07 13:37:39 UTC
SQL Syntax issue
Can we use 2 or more tables in UPDATE clause?
eg. UPDATE T1, T2
SET T1.name = 'abc'
WHERE T1.id = T2.id
Re: SQL Syntax issue
Posted by Rick Hillegas <Ri...@Sun.COM>.
Priyanka Karnawat wrote:
> Can we use 2 or more tables in UPDATE clause?
> eg. UPDATE T1, T2
> SET T1.name = 'abc'
> WHERE T1.id = T2.id
Hi Priyanka,
I'm not sure what you are trying to do, but the following query may help:
update t1
set name ='abc'
where id in ( select id from t2 );
Hope this is useful,
-Rick
RE: SQL Syntax issue
Posted by Kamesh Parameswaran <ka...@cisco.com>.
I guess you need a stored procedure to update multiple tables. The
statements can be wrapped within a transaction. If possible send me your use
case. I'll see how it can be done
~Kamesh
_____
From: Priyanka Karnawat [mailto:priyanka@sungraceinfotech.co.in]
Sent: Friday, August 07, 2009 5:08 PM
To: derby-user@db.apache.org
Subject: SQL Syntax issue
Can we use 2 or more tables in UPDATE clause?
eg. UPDATE T1, T2
SET T1.name = 'abc'
WHERE T1.id = T2.id
RE: SQL Syntax issue
Posted by Kamesh Parameswaran <ka...@cisco.com>.
If the below mentioned example is your use case, you can try what Segel
suggested.
~Kamesh
_____
From: Michael Segel [mailto:msegel@segel.com] On Behalf Of derby@segel.com
Sent: Friday, August 07, 2009 6:05 PM
To: 'Derby Discussion'
Subject: RE: SQL Syntax issue
Why do you need two tables in your update?
Its not really a nested query but an Update statement where you use a select
statement to help qualify the Update.
See the standard SQL syntax on this.
_____
From: Ravinder Reddy [mailto:ravinder.pandiri@gmail.com]
Sent: Friday, August 07, 2009 7:06 AM
To: Derby Discussion
Subject: Re: SQL Syntax issue
Hi,
I think , you can't do that.
Instead use nested queries (I am not sure Derby supports nested queries
though).
On Fri, Aug 7, 2009 at 5:07 PM, Priyanka Karnawat
<pr...@sungraceinfotech.co.in> wrote:
Can we use 2 or more tables in UPDATE clause?
eg. UPDATE T1, T2
SET T1.name = 'abc'
WHERE T1.id = T2.id
--
Ravinder Reddy
RE: SQL Syntax issue
Posted by de...@segel.com.
Why do you need two tables in your update?
Its not really a nested query but an Update statement where you use a select
statement to help qualify the Update.
See the standard SQL syntax on this.
_____
From: Ravinder Reddy [mailto:ravinder.pandiri@gmail.com]
Sent: Friday, August 07, 2009 7:06 AM
To: Derby Discussion
Subject: Re: SQL Syntax issue
Hi,
I think , you can't do that.
Instead use nested queries (I am not sure Derby supports nested queries
though).
On Fri, Aug 7, 2009 at 5:07 PM, Priyanka Karnawat
<pr...@sungraceinfotech.co.in> wrote:
Can we use 2 or more tables in UPDATE clause?
eg. UPDATE T1, T2
SET T1.name = 'abc'
WHERE T1.id = T2.id
--
Ravinder Reddy
Re: SQL Syntax issue
Posted by Ravinder Reddy <ra...@gmail.com>.
Hi,
I think , you can't do that.
Instead use nested queries (I am not sure Derby supports nested queries
though).
On Fri, Aug 7, 2009 at 5:07 PM, Priyanka Karnawat <
priyanka@sungraceinfotech.co.in> wrote:
> Can we use 2 or more tables in UPDATE clause?
> eg. UPDATE T1, T2
> SET T1.name = 'abc'
> WHERE T1.id = T2.id
>
--
Ravinder Reddy