How do I put a previous result into the next query? MYSQL

omarisgod

Okay so, this is my query.

select id from rooms where owner = 'oknow';

and the answer I get is

325

However, I made another SQL within this one as below

update users set home_room = 'mysql_fetch_assoc()' where username = 'omarisgod';

I want the 'mysql_fetchassoc()' to be the '325' value, how do I do this?

Redbeard011010

A subquery will do this:

UPDATE users SET home_room = (SELECT id FROM rooms WHERE owner = 'oknow') WHERE username = 'omarisgod';

You can conceptualize it thusly: The query inside parentheses will return a result, which will be utilized by the outer query.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how do i get last result in group by MySQL query (not the first)

From Dev

How do I query previous rows?

From Dev

In Mysql, How do i determine the row size returned by the previous select query in a stored procedure?

From Dev

How do I stop the cardlayout .next() and .previous() from looping

From Dev

How do I loop through images with Previous/Next buttons?

From Dev

How do I call the next and the previous value in an array with a button?

From Dev

Scroll to next and previous div using scrollTop, how do I accomplish this?

From Dev

How do I calculate the next/previous ISO weekday number?

From Dev

How do I add a previous and next button to ListView

From Dev

How to add custom query parameters to next/previous links in paged hateoas result?

From Dev

How to put result of query in a variable?

From Dev

How to put result of query in a variable?

From Dev

How do I put text that is inside a P element next to a image?

From Dev

How do I put these 2 dates next to each other?

From Dev

How do I put text next to bordered text?

From Dev

How do I use more "select query" with Mysql to get result from different table

From Dev

How do I create MySQL query to get result from different year?

From Dev

Where do I put the SET values in a mysql query

From Dev

How do I put a boolean result into a variable in Powershell?

From Dev

How do I call Peekable::next based on the result of Peekable::peek?

From Dev

How do I query SQlite using python and then compare the query result?

From Dev

Next query is not executed until I materialize previous query by Entity Framework

From Dev

How do I put distinct values from a LINQ query into a list?

From Dev

How do I put multiple variables into a SQL query

From Dev

How do I query with a join getting all the data in Om Next?

From Dev

Android: how do I check data change or not if I edit data in next activity and go back to previous

From Dev

How do I change the active class to the LI element when I click next/previous button?

From Dev

How can I insert the query result into a table in mysql?

From Dev

How do I optimize my query in MySQL?

Related Related

  1. 1

    how do i get last result in group by MySQL query (not the first)

  2. 2

    How do I query previous rows?

  3. 3

    In Mysql, How do i determine the row size returned by the previous select query in a stored procedure?

  4. 4

    How do I stop the cardlayout .next() and .previous() from looping

  5. 5

    How do I loop through images with Previous/Next buttons?

  6. 6

    How do I call the next and the previous value in an array with a button?

  7. 7

    Scroll to next and previous div using scrollTop, how do I accomplish this?

  8. 8

    How do I calculate the next/previous ISO weekday number?

  9. 9

    How do I add a previous and next button to ListView

  10. 10

    How to add custom query parameters to next/previous links in paged hateoas result?

  11. 11

    How to put result of query in a variable?

  12. 12

    How to put result of query in a variable?

  13. 13

    How do I put text that is inside a P element next to a image?

  14. 14

    How do I put these 2 dates next to each other?

  15. 15

    How do I put text next to bordered text?

  16. 16

    How do I use more "select query" with Mysql to get result from different table

  17. 17

    How do I create MySQL query to get result from different year?

  18. 18

    Where do I put the SET values in a mysql query

  19. 19

    How do I put a boolean result into a variable in Powershell?

  20. 20

    How do I call Peekable::next based on the result of Peekable::peek?

  21. 21

    How do I query SQlite using python and then compare the query result?

  22. 22

    Next query is not executed until I materialize previous query by Entity Framework

  23. 23

    How do I put distinct values from a LINQ query into a list?

  24. 24

    How do I put multiple variables into a SQL query

  25. 25

    How do I query with a join getting all the data in Om Next?

  26. 26

    Android: how do I check data change or not if I edit data in next activity and go back to previous

  27. 27

    How do I change the active class to the LI element when I click next/previous button?

  28. 28

    How can I insert the query result into a table in mysql?

  29. 29

    How do I optimize my query in MySQL?

HotTag

Archive