i have 2 tables named "sales" and "rsales" ,
and now i have this ff data from "sales"
id | pcode | total |
2 | 122 | 20 |
3 | 122 | 20 |
4 | 321 | 30 |
5 | 321 | 30 |
don't wonder why i have duplication of pcode,total,discount, it's simply because when i "add order" or click my submit button it saves to the tble "sales" in that way like what i have illustrated above. i have this code to share with you how to update my tbl "sales" and it works very well. what i did is that i get the id. let say for example i get the id "1" from "sales" so when i run my query below it update id "1" but also id "2" because they are the same "pcode" it's obvious to my query. i have no problem updating my tbl "sales"
mysql_query("UPDATE sales SET total = '$total_discount' where pcode = '$pcode' ");
so my problem is this i have this ff codes to update my tbl "rsales
mysql_query("UPDATE rsales SET total = '$total_discount' ,discount = '$tot' WHERE rsales.sales_id IN (SELECT sales.id FROM sales)");
what i want is that when i update specific pcode in my tbl "sales" the tbl "rsales" must be update also. so let say for example i update "total" from "sales" by pcode 122., so from 20 i change it to 40 , so my tbl "rsales" must be look like this way
id | pcode | total | sales_id|
2 | 122 | 40 | 2 |
3 | 122 | 40 | 3 |
4 | 321 | 30 | 4 |
5 | 321 | 30 | 5 |
butmy query is showing me this result. allvrows updating.i can't update exactly the "total" from "rsales" pls help me. every help is very helpful.
id | pcode | total | sales_id|
2 | 122 | 40 | 2 |
3 | 122 | 40 | 3 |
4 | 321 | 40 | 4 |
5 | 321 | 40 | 5 |