我需要选择并更新一个从其他表中查找值的表。这个想法是从 order 中选择一些细节,但使用 id 获取外键值的名称
对于我尝试的选择:
SELECT [Order].order_date,
[Order].total_price,
[Order].order_details,
vehicle.reg_no,
Staff.name,
stock.name
FROM
Order,
vehicle,
staff,
stock
WHERE
order.id = @order_id
AND vehicle.id = Order.vehicle_id
AND staff.id = Order.staff_id
AND stock.id = Order.product_id
对于我尝试的更新
UPDATE order
SET
total_price = @total_price,
order_detail = @order_detail,
product_id = (select is from stock where name = @product_name),
customer_id = (select id from customer where name = @customer_name),
vehicle_regno = (select reg_no from vehicle where name = @name)
WHERE (id = @id)
两者都不返回任何东西。我希望足够清楚以获得一些帮助,但如果不是,我会提供更多信息。
谢谢你的帮助