I want to update a colume using results from an select query but its not working :( my code:

UPDATE goods
SET goods.wagons_needed = (SELECT (goods.QUANTITY * WEIGHT) / max_payload as wneed
FROM GOODS INNER JOIN wagon_type 
ON goods.wagon_type_id = wagon_type.wagon_type_id
order by goods.goods_id)
where goods.goods_id = goods.goods_id;

Thanks for any help.

Recommended Answers

All 2 Replies

What error do you get?

Perhaps because your select can return multiple results? Try LIMIT 1.

give your table structure? It seems your select query is returning multiple record.Try running the select query sepately in your mysql client and check its output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.