当前位置:网站首页>SQLite common function integration
SQLite common function integration
2022-07-27 07:30:00 【Xiongsiyu】
Catalog
SQLite date 、 Time Comparison method
SQLite Prompt error :SQLite error near “@table“: syntax error
SQL Create table ,ID Set up key, And self increase
SQLite Query maximum , Returns the entire line of data
SQLite date 、 Time Comparison method
One 、 new table
The following software is Navicat 15 for SQLite
Create a new table for testing test, Add two fields ,id,myTimer,myTimer Format for datetimer

Two 、 insert data
Query the current time
SELECT DATETIME('now','localtime')result :

Know how to get the current time , We ask test Insert data into the table
INSERT INTO test(myTimer) VALUES(DATETIME('now','localtime'))Randomly generate a few pieces of data , For the following query , as follows :

3、 ... and 、 Compare time
1. The query is greater than 2022-02-22 16:45:59 The data of
SELECT * FROM test WHERE myTimer > '2022-02-22 16:45:59'function :

You can see , The query result is right .
occasionally , It should be noted that , use Where The following query conditions are used “2022-02-22 12:00:00” This format is used for comparison , There will be exceptions , The results are all messy , Completely with Where The condition in does not meet , You can check my post : Click the jump
stay C# When the time is displayed on the , You can use the following format :
DateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));The display is the same as the above
SQLite Prompt error :SQLite error near “@table“: syntax error
I wrote it before C# operation SQLite In the post , I found that sometimes the following errors occur during operation :
SQLite error near "@table": syntax error

The error code is as follows :
public static Tuple<bool, DataSet, string> GetBarcode(string barcode)
{
if (string.IsNullOrEmpty(barcode))
{
return new Tuple<bool, DataSet, string>(false, null, " The passed parameter cannot be empty ");
}
string sql = "SELECT * FROM @table WHERE Barcode = @barcode";
SQLiteParameter[] parameter = new SQLiteParameter[]
{
new SQLiteParameter("table", " Database table name "),
new SQLiteParameter("barcode", barcode)
};
return SQLiteHelpers.ExecuteDataSet(sql, parameter);
}SQLiteHelpers See my previous post for my script : Click the jump
resolvent :
I find , Database table name cannot be added to SQLiteParameter In the parameter list , Other column names are OK ,SQL The statement will not report an error if it is connected by string , as follows :
public static Tuple<bool, DataSet, string> GetBarcode(string barcode)
{
if (string.IsNullOrEmpty(barcode))
{
return new Tuple<bool, DataSet, string>(false, null, " The passed parameter cannot be empty ");
}
string sql = string.Format("SELECT * FROM {0} WHERE Barcode = @barcode", " Database table name ");
SQLiteParameter[] parameter = new SQLiteParameter[]
{
new SQLiteParameter("barcode", barcode)
};
return SQLiteHelpers.ExecuteDataSet(sql, parameter);
}SQL Create table ,ID Set up key, And self increase
sql The statement is as follows :
CREATE TABLE user
(
ID integer PRIMARY KEY AUTOINCREMENT,
UserName text NOT NULL,
Age int NOT NULL
)
SQLite Query maximum , Returns the entire line of data
Query maximum
SELECT MAX( Name ) FROM Table name Query maximum , Returns the entire line of data
SELECT * FROM Table name WHERE Name = (SELECT MAX( Name ) FROM Table name ) LIMIT 1;SQLite Add index
open SQLite Studio, Create a new table student, Add a few fields :id、name、age、address
Click on Create index

The following interface will be opened
Sort( Sort )
ASC Expressing ascending order
DESC Representation of descending order

Here in the collation
Collation( Sort rule )
RTRIM Clear the space character at the end of the string
NOCASE Disable case sensitivity
BINARY Binary system

SQL sentence :
example 1
CREATE INDEX findName ON student (
name COLLATE BINARY ASC
);
COLLATE It's sort rules
example 2
CREATE INDEX findTestTime ON sampleRecord (
TestTime ASC
);
findTestTime Is the index name ,
sampleRecord Is the name of the table ,
TestTime Field name ,
ASC Represents ascending order
end
边栏推荐
- flink原理(一) 状态的TTL管理、容错机制
- 12. Integer to Roman
- Overall dichotomy?
- View the dmesg log before server restart
- oracle的触发器的使用举例
- Using loops to process data in tables in kettle
- 【QT】capture.obj:-1: error: LNK2019: 无法解析的外部符号 __imp_htons(解决方法)
- 【golang学习笔记2.1】 golang中的数组中的排序和查找
- Expose Prometheus metrics in Perl programs
- Federal Reserve SR 11-7: Guidance on model risk management - Wanzi collection
猜你喜欢

(2022 Niuke multi school III) a-ancestor (LCA)

一款开源 OA 办公自动化系统

Use reflection to dynamically modify annotation attributes of @excel

Internal class -- just read this article~

用户解锁SM04 SM12

Use of tigervnc

SQLite 常用功能整合

Codeforces Round #810 (Div.2) A-C

(2022牛客多校三)J-Journey(dijkstra)

Array method and loop in JS
随机推荐
ShowDoc漏洞学习——CNVD-2020-26585(任意文件上传)
Oracle database problems
Using docker in MAC to build Oracle database server
DRConv-pytorch改称输出和输入一样的尺寸
单元测试系统化讲解之Mockito
C语言程序设计 | 程序编译与预处理
漏风的小棉袄……
UI gesture actions of uiautomator common classes
Usage of string class
Want to sink into redis hash and write in the attributes and values of the object. Do the bosses have a demo?
[Vani has a date] tail on rainy days
Will Flink CDC constantly occupy Oracle's memory by extracting Oracle's data, and finally cause oracle-040
flink中维表Join几种常见方式总结
(2022 Hangdian multi school III) 1009.package delivery (greedy)
Examples of Oracle triggers
在mac中使用docker来搭建oracle数据库服务器
Jmeter: interface automation test - BeanShell compares database data and return data
海康h9摄像头用xshell无法连接(没有启用ssh)
Excuse me, MySQL timestamp (6) using flick SQL is null. Is there a way to deal with this
Use shell to calculate the sum of numbers in text