mysql database foundation "CRUD" learning

1. The basic syntax query
all fields (1) queries the table unconditionally
select * from table; // * all columns of the table
(2) all the fields of the table query qualified
select * from table where field name = '' value ';
(3) querying the table qualified field
select field 1, field 2 from table where field name =' value ';
(4) a number of conditions for the query statement written
select * from table where field > field value and <value; // logical aND operation
select * from table where field> value or field> value; // logical oR
select * from table where = not field "value"; // do not meet the query if the condition of the
select * from table where field between value and value; // between ... and ... the scope of the query constraints
select * from table where field in (value 1, value 2, 3 value); // value is in line with where the query or a value similar to the use of
(5) Fuzzy query
select * from table where field like "_m%"; //% _ represents a plurality of characters representative of characters of the query statement in a second letter m is any field
(6) sorting process
select * from table name order by field asc / desc // Mo In ascending order to recognize the need to increase Descending Descending statements
(7) limit usage
select * from table limit x, y; // x y starting position for the end position if only a few queries, compared with the number of records
2. Insert the basic syntax
(1) insert into table (Field 1, Field 2 , field 3) values (value 1, value 2 and value 3);
3. update basic syntax
(1) update table set field = 1 "value 1", 2 = field "value 2" WHERE field 3 = "value 3 ";
4. remove the basic syntax
(1) delete from table where field = 1" value 1 ";

The first written, badly written the wrong place also pointed out hope

Released two original articles · won praise 3 · Views 155

Guess you like

Origin blog.csdn.net/weixin_43160903/article/details/104288555