Mysql 常用方法
阿新 • • 發佈:2022-11-29
刪除重複資料(根據url刪除重複資料)
DELETE FROM `BaiDu_know_new_copy1` WHERE
`user_url` IN (
SELECT x FROM
(
SELECT `user_url` AS x
FROM `BaiDu_know_new_copy1`
GROUP BY `user_url`
HAVING COUNT(`user_url`) > 1
) tmp0
)
AND
`id` NOT IN (
SELECT y FROM
(
SELECT min(`id`) AS y
FROM `BaiDu_know_new_copy1`
GROUP BY `user_url`
HAVING COUNT(`user_url`) > 1
) tmp1
)
更新資料
UPDATE loctek_shop_price SET sku_name=%s ,sku_price=%s,date=%s WHERE id= %s
插入資料
sql = 'insert into baidu_know_url_new(`source`,url) value (%s,%s)'
va = (laiyuan, question_url)
cursor.execute(sql, va)
conn.commit()
一段資料插入一個新表
insert into beauty_copy1 select * from beauty limit 10
刪除一段資料
delete from beauty limit 10
刪除表中某欄位下為空的資料
delete from 表名 where 欄位名 is null;
delete from tiktoktext where text=''
替換
update loctek_shop_price set shop_type=REPLACE(shop_type,'站立健康辦公','經銷商')
查詢某個字串是否在欄位裡面 Attachment 欄位名
select * from EASA_AD where INSTR(Attachment,'0103_Espagnol.pdf')
UPDATE user SET name=LTRIM(name);
去掉右邊空格
UPDATE user SET name=RTRIM(name);
去掉全部(左右)空格
UPDATE user SET name=TRIM(name);