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

     

     

  • 相关阅读:
    Linux C++ 处理 Kill 信号、Ctrl+C信号,便于安全退出
    静态链接libcurl的步骤
    编译器如何C++的函数重载
    单链表逆序 也叫反转
    VC 创建拨号连接A
    强大的vim配置,让编程更随意
    已知二叉树后序遍历序列是DBCEFGHA,中序遍历序列EDCBAHFG,它的前序遍历的序列是?麻烦再画下这二叉树.
    怎样使用IPV6编程
    全面详细介绍libcurl的使用
    ZeroMQ全面介绍
  • 原文地址:https://www.cnblogs.com/xiaobaizhu/p/3430453.html
Copyright © 2011-2022 走看看