Summary of SQL syntax not supported by SQLite

Source: Internet
Author: User

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 "+.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.