I have two tables named sales
and rsales
I have this ff value for table sales
id | pcode | total | discount |
2 | 33 | 100 | 20 |
3 | 33 | 100 | 20 |
and i have this ff value for table rsales
id | pcode | total | discount | sales_id |
4 | 33 | 100 | 20 | 1 |
5 | 33 | 100 | 20 | 2 |
6 | 33 | 100 | 20 | 3 |
My problem is that when I update all values from table sales
, the table rsales
must be update either if sales.id
is equal to sales_id
.
so for example if I have updated table sales
with id
= 2 and 3, the sales_id
2 and 3 from rsales
must be updated either.
take note : only 2 and 3 because only that id
s is found in table sales
id
s.
I have this ff codes so far to update table rsales
. but the output is shown not as what I meant. it update all values.
mysql_query("UPDATE sales AS t1, rsales AS t2
SET t1.total = '$total_discount',
t2.total = '$total_discount',
t2.discount = '$tot'
WHERE t1.pcode = '$pcode'");