The difference between using SQL and other databases in SQLite

Source: Internet
Author: User
Tags sqlite

SQLite is widely used as a mainstream database in Android, but there are some differences between his SQL language and the SQL language used in general large databases, as summarized in this article:

1. TOP

In SQL Server, we use top to get the top N data:

SELECT TOP Ten * from [index] ORDER by IndexID DESC;

But in SQLite, people will find that this is not possible, we need to write:

SELECT * FROM [index] ORDER by IndexID DESC limit 0, 10;

Use limit to achieve top functionality.

2. COUNT (DISTINCT column)

SQLite cannot execute the following statement:

SELECT COUNT (DISTINCT watchid) from [Watch_item] WHERE watch_item.watchid = 1;

The reason is that all of SQLite's built-in functions do not support distinct qualification, so there is some trouble if you want to count the number of records that are not duplicated. It is more feasible to first create a view of the record table that is not duplicated, and then count the view. or when inserting data, you need to use the primary key to judge.

3, SQLite can not use the external connection

There is a way to solve the problem, please advise ....

4. Exists statement

This is written in SQL Server:

This is what SQLite writes:

INSERT into AA (nickname) select ' t ' where isn't exists (SELECT * from AA where ids=5)

If there is something new, welcome you to add a message.

Above.










The difference between using SQL in SQLite and other databases

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.