dbTalk Databases Forums  

Updating a permanent table when it is joined with a temporary table.

comp.databases.mysql comp.databases.mysql


Discuss Updating a permanent table when it is joined with a temporary table. in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joseph Hesse
 
Posts: n/a

Default Updating a permanent table when it is joined with a temporary table. - 10-15-2011 , 02:25 PM






Hi,

I have the following situation.

CREATE TEMPORARY TABLE T2 ...;
CREATE TEMPORARY TABLE T3 FROM T1 JOIN T2 ON ...;
In the above JOIN, T1 is a permanent table.

UPDATE T3
SET
T1.field = value
WHERE ...;

When I execute the above query there are no errors and mysql indicated 2
rows were changed.

When I examine T1.field in T3 I find it is correctly changed.
When I examine T1.field in T1 it is unchanged.
I expected T1.field in T1 to have the new value.

Any help would be appreciated.

Thank you,
Joe

Reply With Quote
  #2  
Old   
Luuk
 
Posts: n/a

Default Re: Updating a permanent table when it is joined with a temporarytable. - 10-15-2011 , 02:42 PM






On 15-10-2011 21:25, Joseph Hesse wrote:
Quote:
Hi,

I have the following situation.

CREATE TEMPORARY TABLE T2 ...;
CREATE TEMPORARY TABLE T3 FROM T1 JOIN T2 ON ...;
In the above JOIN, T1 is a permanent table.

UPDATE T3
SET
T1.field = value
WHERE ...;

When I execute the above query there are no errors and mysql indicated 2
rows were changed.

When I examine T1.field in T3 I find it is correctly changed.
When I examine T1.field in T1 it is unchanged.
I expected T1.field in T1 to have the new value.

Any help would be appreciated.

Thank you,
Joe
You are updating T3, which is a TEMPORARY TABLE....
so, of course, you are nog seeing your changes in T1

Why would the original change, if the copy is altered?

--
Luuk

Reply With Quote
  #3  
Old   
Joseph Hesse
 
Posts: n/a

Default Re: Updating a permanent table when it is joined with a temporarytable. - 10-15-2011 , 02:52 PM



On 10/15/2011 02:42 PM, Luuk wrote:
Quote:
On 15-10-2011 21:25, Joseph Hesse wrote:
Hi,

I have the following situation.

CREATE TEMPORARY TABLE T2 ...;
CREATE TEMPORARY TABLE T3 FROM T1 JOIN T2 ON ...;
In the above JOIN, T1 is a permanent table.

UPDATE T3
SET
T1.field = value
WHERE ...;

When I execute the above query there are no errors and mysql indicated 2
rows were changed.

When I examine T1.field in T3 I find it is correctly changed.
When I examine T1.field in T1 it is unchanged.
I expected T1.field in T1 to have the new value.

Any help would be appreciated.

Thank you,
Joe

You are updating T3, which is a TEMPORARY TABLE....
so, of course, you are nog seeing your changes in T1

Why would the original change, if the copy is altered?

I thought that the T1 fields in the join would refer to the original T1
fields.

Reply With Quote
  #4  
Old   
Joseph Hesse
 
Posts: n/a

Default Re: Updating a permanent table when it is joined with a temporarytable. - 10-15-2011 , 03:21 PM



On 10/15/2011 02:52 PM, Joseph Hesse wrote:
Quote:
On 10/15/2011 02:42 PM, Luuk wrote:
On 15-10-2011 21:25, Joseph Hesse wrote:
Hi,

I have the following situation.

CREATE TEMPORARY TABLE T2 ...;
CREATE TEMPORARY TABLE T3 FROM T1 JOIN T2 ON ...;
In the above JOIN, T1 is a permanent table.

UPDATE T3
SET
T1.field = value
WHERE ...;

When I execute the above query there are no errors and mysql indicated 2
rows were changed.

When I examine T1.field in T3 I find it is correctly changed.
When I examine T1.field in T1 it is unchanged.
I expected T1.field in T1 to have the new value.

Any help would be appreciated.

Thank you,
Joe

You are updating T3, which is a TEMPORARY TABLE....
so, of course, you are nog seeing your changes in T1

Why would the original change, if the copy is altered?

I thought that the T1 fields in the join would refer to the original T1
fields.
I found that if I do the UPDATE and JOIN together it works as I want.
UPDATE T1 JOIN T2 ON ...
SET
T1.field = value
WHERE ...;
Thank you.

Reply With Quote
  #5  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: Updating a permanent table when it is joined with a temporary table. - 10-15-2011 , 03:56 PM



Quote:
CREATE TEMPORARY TABLE T2 ...;
CREATE TEMPORARY TABLE T3 FROM T1 JOIN T2 ON ...;
In the above JOIN, T1 is a permanent table.

UPDATE T3
SET
T1.field = value
WHERE ...;

When I execute the above query there are no errors and mysql indicated 2
rows were changed.

When I examine T1.field in T3 I find it is correctly changed.
How can you possibly have a T1.field *in T3*? Is this some kind
of schizoid column that doesn't know what table it is in? You can
have a T3.field, but it's not a T1.field.

Isn't that a little bit like having a Paris, Texas, USA *in France*?

Quote:
When I examine T1.field in T1 it is unchanged.
I expected T1.field in T1 to have the new value.
Where else could T1.field be besides table T1?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.