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

     

     

  • 相关阅读:
    測试AtomicInteger与普通int值在多线程下的递增操作
    《漫画线性代数》读书笔记 矩阵
    Android下雪动画的实现
    Live555实战之交叉编译live555共享库
    JAVA_SE基础——24.面向对象的内存分析
    Linux下利用signal函数处理ctrl+c等信号
    tomcat6url请求400错误(%2F与%5C)
    python的交互式shell-ipython体验
    1906月读书清单
    Linux对变量的截取替换
  • 原文地址:https://www.cnblogs.com/xiaobaizhu/p/3430453.html
Copyright © 2011-2022 走看看