From: Jack Gao <wei@gaofamily.org>
To: pgsql-sql@postgresql.org
Subject: Is this a bug?
Date: Mon, 12 Nov 2001 21:20:44 -0800
Message-ID: <9sqakt$op1$1@news.tht.net> (raw)
Hi, There
When I use Update with Join, I got some problem.
I have a table as user config table (tblUserConfig), and another table as
config item table (tblConfigItem).
CREATE TABLE tblUserConfig (
ID integer NOT NULL DEFAULT nextval('tblUserConfig_pKey_ID')
PRIMARY KEY,
UserID integer NOT NULL, -- tblUser
ItemID integer NOT NULL, -- tblConfigItem
Value varchar(1024)
);
CREATE TABLE tblConfigItem (
ID integer NOT NULL DEFAULT nextval('tblConfigItem_pKey_ID')
PRIMARY KEY,
Scope integer NOT NULL DEFAULT 1, -- 1: System
config, 2: Section config, 3: User config
Name varchar(64) NOT NULL,
Description varchar(64),
DataType integer NOT NULL DEFAULT 1, -- 1: String, 2:
Numeric, 3: Boolean, 4: DateTime
DefaultValue varchar(1024)
);
Now, I would like to update tblUserConfig to set Value of 'UserClassID' to,
for example '1'. So I write a sql string like this:
Update tblUserConfig Set Value = '1' From tblUserConfig As a Join
tblConfigItem As b On a.ItemID = b.ID And b.Scope = 3 Where a.UserID = 1 And
b.Name = 'UserClassID';
It always update all records in tblUserConfig table!!!
If I change it to:
Update tblUserConfig Set Value = '1' Where UserID = 1 And ItemID = (Select
ID From tblConfigItem Where Scope = 3 And Name = 'UserClassID');
It works fine.
So, is this a bug? or I make anything wrong?
Thanks
Noodle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: wei@gaofamily.org
Subject: Re: Is this a bug?
In-Reply-To: <9sqakt$op1$1@news.tht.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox