Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
You can do subquery for your value, example
subquery
UPDATE table1 SET val = ( SELECT COUNT(page) FROM table2 WHERE order_no = 1 )
Add a comment
Warning: #1366 Incorrect integer value: '(SELECT COUNT(page) FROM table2 WHERE id=1)' for column 'fajlok_szama' at row 1
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.