I have 3 tables:
tbl_indicator
grp_nbr, sect_nbr, indicat
1 100 p
2 101 s
tbl_group
grp_id, grp_nbr, sect_nbr, indicat
333 1 100 a
555 1 100 p
444 2 101 s
222 2 101 y
Here (in tbl_group
) grp_id is Primary Key
tbl_order
order_id, grp_id
5000 333
5001 555
5002 555
5003 555
5004 444
5005 444
5006 222
Here (in tbl_order
) grp_id
is a Foreign Key to grp_id
in tbl_group
.
In table tbl_indiactor, for one set of grp_nbr and sect_nbr there is an indicat, for the same set of grp_nbr and sect_nbr there is a correct indicat(555,1, 100, p) and a junk indicat(333, 1, 100, a) in table tbl_group, but both these grp_id s(333, 555) are present in table tbl_orders.
Now i need to update tbl_order table in such a way that the junk grp_id s should be replaced with correct grp_id s
The output should like:
tbl_orders
order_id, grp_id
5000 555
5001 555
5002 555
5003 555
5004 444
5005 444
5006 444
here is a small change
tbl_indicator
grp_nbr, sect_nbr, indicat
01 100 p
02 101 s
tbl_group
grp_id, grp_nbr, sect_nbr, indicat
333 01 100 a
555 01 100 p
444 02 101 s
222 2 101 y
Here (in tbl_group) grp_id is Primary Key
the junk data(indicat) in group table (222, 22, 101, y) the grp_nbr has one character length but the grp_nbr in tbl_indicat has two character length...
how can we handle this??
See Question&Answers more detail:
os