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:注意这里没有*

     

     

  • 相关阅读:
    二叉树的线索
    关于JavaScript变量提升的理解
    HTML label标签的一点理解
    超详细轮播图,让你彻底明白轮播图!
    javascript 入门——this属性的理解!
    《机电传动控制》第二次作业
    第四周学习笔记
    学习笔记
    linux下,让命令提示符显示完整路径
    kafka api消费集群中kafka数据报错问题
  • 原文地址:https://www.cnblogs.com/xiaobaizhu/p/3430453.html
Copyright © 2011-2022 走看看