1 top
This is a frequently asked question. For example, you can use the following statement in sqlserver to obtain the first 10 records in the record set:
Select top 10 * from [Index] order by indexid DESC;
However, this SQL statement cannot be executed in SQLite. It should be changed:
Select * from [Index] order by indexid DESC limit 0, 10;
Here, limit 0th indicates that 10 records are read from records.
2Create View)
SQLite has a bug when creating a multi-Table view. The problem is as follows:
Create view watch_single as select distinctWatch_item. [watchid], watch_item. [Itemid] From watch_item;
After the preceding SQL statement is executed, it is displayed as successful.
Select count (*) from [watch_single] Where watch _ single. watchid = 1;
Other statements cannot be executed. The reason is that the table name of the field is specified when the view is created, and SQLite cannot identify it correctly. Therefore, the above statement should be changed:
Create view watch_single as select distinct [watchid], [Itemid] From watch_item;
However, what should I do if a multi-Table view has a duplicate Name field between tables?
3 count(Distinct Column)
SQLite reports an error when executing the following statement:
Select count (distinct watchid) from [watch_item] Where watch_item.watchid = 1;
The reason is that all built-in functions of SQLite do not support distinct limitation. Therefore, it is troublesome to count the number of records that are not repeated. It is feasible to create a view of the record table that does not repeat, and then count the view.
4External Connection
Although SQLite officially claims that left Outer Join has been implemented, there is no right Outer Join or full outer join. However, the actual test shows that it does not seem to work properly. When executing the following three statements, an error is reported:
Select tags. [tagid] from [tags], [tag_rss] Where tags. [tagid] = tag_rss. [tagid] (*);
Select tags. [tagid] from [tags], [tag_rss] Where left Outer Join tag_rss. [tagid] = tags. [tagid];
Select tags. [tagid] from [tags], [tag_rss] Where left join tag_rss. [tagid] = tags. [tagid];
In addition, it is not feasible to replace "*" with "+.