PHPmysql basic statement commands

Source: Internet
Author: User
1 * select database 2 usetest; 3*45 * display all databases 6 showdatabases; 7*89 * Delete table database 10dropdatabasetest1; databases; 12*1314 * Create Table 15CREATETABLEuser1 (16idintprimarykeyauto_increment

1/* select database 2 use test; 3 */4 5/* display all databases 6 show databases; 7 */8 9/* Delete table/database 10 drop database test1; 11 delete from user1 where id = 4; 12 */13 14/* create table 15 create table user1 (16 id int primary key auto_increment

1/* select database 2 use test; 3 */4 5/* display all databases 6 show databases; 7 */8 9/* Delete table/database 10 drop database test1; 11 delete from user1 where id = 4; 12 */13 14/* create table 15 create table user1 (16 id int primary key auto_increment, 17 name varchar (32) not null, 18 password varchar (64) not null, 19 email varchar (128) not null, 20 age tinyint unsigned not null ); */21 22/* insert data 23 insert into user1 (name, password, email, age) 24 values ('daomul', md5 ('daomul '), '1970 @ qq.com ', '22'); 25 */26 27/* query data 28 select * from user1; 32 */30 31/* problem solving 32 set character_set_client-gbk; 33 set character_set_result-gbk; 34 35 # show All character types: show variables like '% char % '; 36 37 */

1. query a row of data

"Select name from user1 where age = '". $ age. "'limit;" // control the number of data entries in the 0-1 directory.

2. Fuzzy search

"Select name from user1 where email like '%" $ email "% '";

3. Execute SQL statements in batches

3.1 execute dml statements in batches

(1 $ SQL = "$ sql1; $ SQL ;....";

Or: $ sqls = ""; $ sqls. = ""; $ sqls. = "";....

(2 mysqli: multi_query ($ sqls); // executes the operation and returns the number of operations.

3.2 execute dml statements in batches

Example: see http://www.cnblogs.com/daomul/p/3381782.html

4. self-replication: Highly tested data

Insert into emp (name, grade, email, school, salary, remark) select name, grade, email, school, salary, remark from emp;

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.