mysql update from select on same table 1

mysql update from select on same table

UPDATE users SET status = 1
WHERE id = (
  SELECT id FROM (
    SELECT id FROM users WHERE id = 10
  ) u
)

Here is what the above code is Doing:
1. It’s selecting the id from the users table where the id is 10.
2. It’s selecting the id from the above query.
3. It’s updating the status of the user with the id from the above query.

The above code is not working. I’m getting the following error:

ERROR: more than one row returned by a subquery used as an expression

I’m not sure why I’m getting this error. I’m selecting only one row from the users table.

I’m using PostgreSQL 9.3.

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users SET status = 1
WHERE id = (
SELECT id FROM (
SELECT id FROM users WHERE id = 10
) u
)

I’m using the following code to update the status of the user:

UPDATE users

Similar Posts