Is this a bug?

From: "Jack Gao" <wei(at)gaofamily(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Is this a bug?
Date: 2001-11-13 05:20:44
Message-ID: 9sqakt$op1$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gurudutt 2001-11-13 05:45:43 Joins!!
Previous Message Orion 2001-11-12 20:37:40 Re: Funny Parse Error on Insert