Welcome Guest, Not a member yet? Register   Sign In
SELECT and UPDATE in the same query?
#1

[eluser]kyleect[/eluser]
I have two tables set up: 'users' and 'confirmation_queue' (see below for examples) and how it should work is: query the confirmation_queue with the confirmation_code to get the user_id. update 'users' using the user_id and set 'active' to true. Is this possible with one query?

Code:
users
    id
    active

confirmation_queue
    user_id
    confirmation_code
#2

[eluser]TheFuzzy0ne[/eluser]
Yes, you should be able to do that with a [url="http://dev.mysql.com/tech-resources/articles/subqueries_part_1.html"]subquery[/url].
#3

[eluser]kyleect[/eluser]
Thanks, I'll try that out.




Theme © iAndrew 2016 - Forum software by © MyBB