zoukankan      html  css  js  c++  java
  • 简单常用sql查询

    [self.db executeUpdate:sql, record.recordID];

    CREATE TABLE scene_record(id TEXT PRIMARY KEY, record_time TEXT, location TEXT,place TEXT,description TEXT,isUpdate TEXT,is_delete TEXT)

    按生序查询,并指定查询值

    SELECT * FROM scene_record where isUpdate = 1 or isUpdate = 2 order by record_id asc

    按降序排列

    SELECT * FROM scene_record where isUpdate = 1 or isUpdate = 2 order by record_id desc

    条件查询

    SELECT * FROM scene_record where isUpdate = 1 or isUpdate = 2

    未指定查询值

    select * from scene_record where name=?

    查询最大id

    select max(id) from scene_record

    从搜索结果中搜索

    select * from info_tag where parent_id = (select parent_id from info_tag where id=?)

    带有or的条件搜索

    SELECT * FROM scene_record_detail where (is_upload = 1 and is_delete = 0) or (is_upload = 2 and is_delete = 0)

    插入语句:

    插入表中的一列数据

    insert into custom_classify (name) values(?)

    [self.db executeUpdate:sql,classifyName];

    插入全部数据:

    insert into scene_record values(?,?,?,?,?,?,?)

    [self.db executeUpdate:sql,record.recordID,record.recordTime,location, record.place, record.sceneRecordDescription, @"1", @"0"];

    插入指定列:

    insert into scene_record (record_id,record_time,location,place,description,isUpdate,is_delete) values(?,?,?,?,?,?,?)

    [self.dbexecuteUpdate:sql,record.recordID,record.recordTime,record.location,record.place,record.sceneRecordDescription,@"2",@"0"];

    更新语句:

    根据record_id更新一列is_delete

    update scene_record set is_delete = 1 where record_id = ?

    [self.db executeUpdate:sql, record.recordID];

    根据record_id跟新多列location,place,description,isUpdate

    update scene_record set location = ?, place = ?, description = ?, isUpdate = 1 where record_id = ?

    删除语句:

    删除全部:

    delete from test_table

    PS:注意这里没有*

     

     

  • 相关阅读:
    Promise简单使用,需要在ES6以上
    uni-app条件编译:#ifdef #ifndef #endif
    js获取年月日
    js验证手机号、身份证等
    json.stringify()与json.parse()
    Vuex基本使用的总结--转载
    ...mapMutations前面的三个点什么意思
    制作缩略图、远程缩略图
    node整个环境的启动
    redis命令
  • 原文地址:https://www.cnblogs.com/xiaobaizhu/p/3430453.html
Copyright © 2011-2022 走看看