Android Advanced-sql language

Source: Internet
Author: User

--Create a table

The first way

CREATE TABLE T_hui (

ID integer,//

Name text,

Sex text,

The first parameter is the name of the field to be created, and the second parameter is the type of the field

)

The second way

CREATE TABLE T_hui (

ID integer,//PRIMARY KEY autoincrement//set ID as primary key, and self-increment

Name text, unique//unique represents the value of the field can only be unique, cannot have duplicates

Sex text, NOT null default value//NOT NULL means cannot be null, default 20 means 20

The first parameter is the name of the field to be created, and the second parameter is the type of the field

)

--Inserting data

INSERT into T_hui (name,age,sex) VALUES (' Yes ', 18, ' parent ')//Add data to the specified field fields

INSERT into T_hui values (' Yes ', 18, ' parent ')//Add data to all fields, add several values in several fields, or you will get an error

--Modify data

Update T_hui Set name = ' Whitney ', age = 20//Syntax UPDATE t_hui set field 1 = ' Whitney ', field 2 = 20

--Delete data

Delete from T_hui//delete all data in table

Delete from T_hui where name = ' Little Dragon Girl '//Specify delete T_hui table inside Name field for little Dragon Girl data

--Sort Query

Select from T_hui order BY age//Query the data for age in the T_hui table, and sort them in ascending order, Desc is descending

--Summation

Select AVG (age) from T_hui//averaging data for age in T_hui table

Select Max (age) from T_hui//MAX T_hui data for age in table

Select age from T_hui where age in (1,3,4,5,67,7)//Querying Multiple values

--like operator

Select from T_hui where name '% Megumi '//filter data at the end of the benefit

Select from T_hui where name '% Megumi% '//filter data with Benefits

Select from T_hui where name ' Megumi% '//filter data beginning with preference

--Paged Query

Select from T_hui limit 0,8//starting from 0 queries, the number of queries is 8,

SELECT * from T_hui P joins T_tao s on s.id = p.id//union query

Join is the union of two tables together, on is the ID of the Union query

Android Advanced-sql language

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.