MYSQL如何修改查詢出來的結果集

2022-09-19 17:36:12 字數 1045 閱讀 6156

update expresspackage  set isuploadsto=-200

where billcode in

( select billcode

from expresspackage where reallatticeno not in (224,448

) and

`status` = 0 and downtime < '

2022/1/26 15:29:03

'and

createtime

< '

2022/1/26 15:29:03

' and isuploadsto > -20 and isuploadsto < 1

)

執行上訴語句出現you can'

t specify target table for update in from clause 不能在同一表中查詢的資料作為同一表的更新資料。

改成下述語句就行

update expresspackage  set isuploadsto=-200

where billcode in

( select a.billcode

from

( select billcode

from expresspackage where reallatticeno not in (224,448

) and

`status` = 0 and downtime < '

2022/1/26 15:29:03

'and

createtime

< '

2022/1/26 15:29:03

' and isuploadsto > -20 and isuploadsto < 1

) a )

也就是說將select出的結果再通過中間表select一遍,這樣就規避了錯誤。注意,這個問題只出現於mysql,mssql和oracle不會出現此問題。

mysql修改查詢出來結果

需求 之前漢字轉拼音時候發覺有個字母 轉換錯了,應該是v才對,實際上 也沒錯,但是在計算機拼音中 是用v表示的,所以要把表中的 全部轉換為v 一開始覺得這個sql應該也不難,先查詢出來所有的符合條件的然後update 寫出來了發現報錯了。you can t specify target table ...

mysql 查詢出來的資料亂碼,如何解決

mysql會出現中文亂碼的原因不外乎下列幾點 1.server本身設定問題,例如還停留在latin1 2.table的語系設定問題 包含character與collation 3.客戶端程式 例如php 的連線語系設定問題 強烈建議使用utf8,utf8可以相容世界上所有字元 找到這個地方 看看de...

查詢出來內容為null,resultMap相關解答

resultmap常用知識點 resultmap元素,是mybatis對映檔案中最為重要 功能最強大的元素。使用jdbc查詢,返回resultsets,是最為常用的資料庫操作。resultmap的設計,簡化了對映檔案中編寫複雜sql的操作。列名與屬性名對映,一般用於列名和屬性名不一致的情況。resu...