Reputation:
Can I give a query as a value in mysql?
I meen something like this:
UPDATE table1 SET val='X'
where
X= SELECT COUNT(page) AS X FROM table2 WHERE order_no=1
so every time I ask for X it should depend on other tables content
Upvotes: 0
Views: 201
Reputation: 263783
You can do subquery
for your value, example
UPDATE table1
SET val = (
SELECT COUNT(page)
FROM table2
WHERE order_no = 1
)
Upvotes: 1