Subquery returns more than 1 row solution for update query using select statement

后端 未结 2 1262

Hello i have query in which i have written update statement using select statement. But unfortunately getting errors subquery returns more than 1 row. I know where the error is

2条回答
  •  太阳男子
    2021-01-24 12:37

    You have to first think about what you want to do.

    Do you want to fetch one value and save it somewhere else? Then use SET value = (SELECT...). For this you need to make sure, the inner statement doesn't return more than one value.

    Or

    Do you need to be able to handle fetching multiple values? What do you want to do with these? Save all of them? All in one (use concat) or store them individually (one update per result)? Or select one of them? Maybe the first (LIMIT 1) or highest (MAX) or lowest (MIN) value?

提交回复
热议问题