ios-Single-table operations common SQL

Source: Internet
Author: User

--Create a data table that defines the structure of the stored Data information table--CREATE TABLE t_student (Name text, age integer, Phoneno text);--Deleting a data table is usually used when you don't need to use a table , which is rarely used in daily development--DROP TABLE t_student;--new data content, in SQL statements, strings need to be enclosed in single quotation marks--syntax format for INSERT statement:--INSERT into table name (Field 1, Field 2, ...) VALUES (Field 1 value, field 2 value, ...)--INSERT into T_person (name, age, gender, height) VALUES (' Floret 1 ', 1, 1.62);--Update Database Content--Update all records--UPDATE t_person SET name = ' King two leper ';--conditional modification where (where to modify, where to manipulate the record)--UPDATE t_person SET name = ' Small Fang ' WHERE gender = 1;--use and to set the conditions--use or to set or condition--Update the syntax format of a record--UPDATE table name SET Field 1 = Field 1 value, field 2 = Field 2 value, ... WHERE to modify the condition--UPDATE t_person SET name = ' Simon blows Snow ', age = a WHERE age = $ and height = 1.65;--UPDATE t_person SET name = ' Goku ' WHERE age = OR height = 1.72;--Deleting Records--syntax formatting to delete--Delete from table name WHERE to delete condition--DELETE from T_person WHERE height = 1.8;--Query Instructions--SELECT * from T_person;--Conditional Query--check all the men.--SELECT * from T_person WHERE gender = 1;--Inquiry age greater than 10 years old, is also a man--SELECT * from T_person WHERE age > and gender = 0;--Query the total number of records in the person table---SELECT Count (*) from T_person;--Query the tallest height--SELECT max (height) from T_person;--SELECT min (age) from T_person;--Check the average height of all men---SELECT avg (height) from T_person WHERE gender = 0;--Paging Query--starting from the No. 0 record, query 3 records--the first parameter of the LIMIT indicates: Start the query from the number of rows, the starting line is 0--The second parameter of LIMIT indicates the number of records that the query needs to query--SELECT * from T_person LIMIT 0, 3;--SELECT * from T_person LIMIT 3, 3;--SELECT * from T_person LIMIT 6, 3;--Sort--Order By field name to sort--ASC indicates ascending--desc = Descending--if more than one field participates in the sort, first field is followed, and so on, that is: the first field has the highest sort priority! SELECTHeight, name, gender, age fromT_personORDER  byAgeASC, heightDESC;

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.