MySQL Forums
Forum List  »  Newbie

updating using 2 fields in the where clause
Posted by: Donald Campbell
Date: February 20, 2009 03:01AM

I am new to MySQL and I am having a few difficulties with some SQL.
I have to update a few records in a table that have been processed. I have
the sub-set in a temporary table. The complication is that the unique "index"
consists of two fields. Not all combinations of the two fields should be
updated, only those in the temp table.

Main Table
create table enr_invdetail
(
eid_enr_no INTEGER UNSIGNED not null,
eid_sem_no INTEGER UNSIGNED not null,
eid_schdate date,
eid_amount decimal(8,2),
eid_status char(1),
eid_sage_code INTEGER UNSIGNED,
primary key enr_invdetail_PK (eid_enr_no, eid_sem_no),
INDEX enr_invdetail_inx01 (eid_schdate)
)ENGINE = InnoDB;

Temp Table:
create table tp1_file
(
tp1_enr_no INTEGER UNSIGNED not null,
tp1_sem_no INTEGER UNSIGNED not null,
tp1_amount decimal(8,2),
tp1_std_no INTEGER UNSIGNED,
tp1_std_code char(8),
tp1_cor_code char(8),
primary key tp1_file_PK (tp1_enr_no, tp1_sem_no)
)ENGINE = InnoDB;
commit work;


In Unify RDBMS I am used to being able to update comparing the tuple (pair of
fields)
e.g.
update enr_invdetail set eid_status = "D" where (eid_enr_no, eid_sem_no)
IN (select (tp1_enr_no, tp1_sem_no) from tp1_file) ;

MySQL does not like this saying that you can only have a single field.

Any ideas how I can perform the update?

Options: ReplyQuote


Subject
Written By
Posted
updating using 2 fields in the where clause
February 20, 2009 03:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.