php mysql 常用语句_PHP mysql基本语句指令
1 /* 選擇數(shù)據(jù)庫 2 use test; 3 */ 4 5 /* 顯示所有的數(shù)據(jù)庫 6 show databases; 7 */ 8 9 /* 刪除表/數(shù)據(jù)庫 10 drop database test1; 11 delete from user1 where id=4; 12 */ 13 14 /* 創(chuàng)建表 15 CREATE TABLE user1( 16 id int primary key auto_increment
1 /*選擇數(shù)據(jù)庫2 use test;3 */
4
5 /*顯示所有的數(shù)據(jù)庫6 show databases;7 */
8
9 /*刪除表/數(shù)據(jù)庫10 drop database test1;11 delete from user1 where id=4;12 */
13
14 /*創(chuàng)建表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 /*插入數(shù)據(jù)23 insert into user1(name,password,email,age)24 values('daomul',md5('daomul'),'975052664@qq.com','22');25 */
26
27 /*查詢數(shù)據(jù)28 select * from user1;29 */
30
31 /*輸入中文的問題解決32 set character_set_client-gbk;33 set character_set_result-gbk;34
35 #顯示所有字符類型 :show variables like '%char%';36
37 */
1、查詢一行數(shù)據(jù)
"select name from user1 where age=' " .$age. " ' limit 0,1;" //控制在0-1條數(shù)據(jù)
2、模糊查詢
"select name from user1 where email like ' % " $email " %' ";
3、批量執(zhí)行 sql語句
3.1 批量執(zhí)行dml語句
(1 $sql="$sql1;$sql; ....";
或者 :$sqls="" ; $sqls.=""; $sqls.=""; ....
(2 mysqli::multi_query($sqls); //執(zhí)行操作,并返回 操作的數(shù)目。
3.2 批量執(zhí)行dml語句
具體事例:見 http://www.cnblogs.com/daomul/p/3381782.html
4、自我復(fù)制:測試高度的數(shù)據(jù)
insert into emp(name,grade,email,school,salary,remark)select name,grade,email,school,salary,remark from emp;
本文原創(chuàng)發(fā)布php中文網(wǎng),轉(zhuǎn)載請注明出處,感謝您的尊重!
總結(jié)
以上是生活随笔為你收集整理的php mysql 常用语句_PHP mysql基本语句指令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 空间备案多久可以查到(空间备案多久)
- 下一篇: mysql数据导出不完正_【MySQL】