SQL statements in SQLite

Source: Internet
Author: User
Query the same field values in a column of the table.

Example: query the user_id values in the user_id column of sms_user_organ.

Table Name: sms_user_organ
User_id organ_id
4427 549
4428 7
4428 9
4429 394

Query statement
Select * From sms_user_organ
Where (select count (*) from sms_user_organ where user_id = A. user_id)> 1

Query Result
User_id organ_id
4428 7
4428 9

Or write a query statement.
Select a. user_id from sms_user_organ a group by A. user_id having count (*)> 1
Result
User_id
4428
4428 after modification:

Select * from test
Where (select count (*) from test where number = A. Number) = 1

The preceding SQL statement can be used to identify all elements in the database (including all rows and columns)

 

The sum of the number of all rows in the select count (*) from test statistical table

Select a. Number from test a group by A. number having count (*)> 1. Check the repeated elements in the number column.

Select a. Number from test a group by A. number having count (*) = 1 find all non-repeating elements in the Number Column

Select a. Number from test a group by A. Number: Check that all elements in the number column are repeated once.

Select number from test to find all the elements whose column name is number in the test table.

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.