自学内容网 自学内容网

sqlite更新

sqlite更新字段

UPDATE tab1
  SET field1 = field1 || '-',
      field2 = field2 + 1
  WHERE ID < 10

UPDATE tab1
  SET (field1, field2) = (field1 || '-', field2 + 1)
  WHERE ID < 10

表关联更新

UPDATE tab1
  SET field1 = (SELECT tab2.field3 FROM tab2 WHERE tab2.FID = tab1.ID),
  WHERE EXISTS (SELECT * FROM tab2 WHERE tab2.FID = tab1.ID)

UPDATE tab1
  SET (field1, field2) = (SELECT tab2.field3, tab2.field4 FROM tab2 WHERE tab2.FID = tab1.ID)
  WHERE EXISTS (SELECT * FROM tab2 WHERE tab2.FID = tab1.ID) 

原文地址:https://blog.csdn.net/qtvb1987/article/details/143672307

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!