mysql select update

Asked 2 years ago, Updated 2 years ago, 123 views

select name from DB limit 0,1; in mysql

This query will output a total of one record from 0 records for the data in the field name in a table called DB.

What I want is to update that selected data. But... I've been googling for four hours. There's no answer.

I'm posting this to ask for advice. Most of them are codes that are merged by referring to two tables. How do I get the answer?

mysql select

2022-09-22 08:08

1 Answers

It's not a big deal if you have a height.

UPDATE DB /* The table name is DB, right? */
  SET name = 'goddamn new name'
  WHERE id = (
    SELECT id FROM DB LIMIT 0, 1
  )

If you don't have a key, you can try the following Untested source SQL.

UPDATE DB
  SET name = 'bloody new name'
  WHERE name IN (
    SELECT name FROM (
      SELECT name FROM DB LIMIT 0, 1
    ) temp_name_list
  )

What is the real problem situation?


2022-09-22 08:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.