PHP mysql基本语句指令
1 /* 选择数据库 2 use test; 3 */ 4 5 /* 显示所有的数据库 6 show databases; 7 */ 8 9 /* 删除表/数据库 10 drop database test1; 11 delete from user1 where id=4; 12 */ 13 14 /* 创建表 15 CREATE TABLE user1( 16 id int primary key auto_increment
<span> 1</span> <span>/*</span><span>选择数据库 </span><span> 2</span> <span> use test; </span><span> 3</span> <span>*/</span> <span> 4</span> <span> 5</span> <span>/*</span><span> 显示所有的数据库 </span><span> 6</span> <span> show databases; </span><span> 7</span> <span>*/</span> <span> 8</span> <span> 9</span> <span>/*</span><span>删除表/数据库 </span><span>10</span> <span> drop database test1; </span><span>11</span> <span> delete from user1 where id=4; </span><span>12</span> <span>*/</span> <span>13</span> <span>14</span> <span>/*</span><span>创建表 </span><span>15</span> <span> CREATE TABLE user1( </span><span>16</span> <span>id int primary key auto_increment, </span><span>17</span> <span>name varchar(32) not null, </span><span>18</span> <span>password varchar(64) not null, </span><span>19</span> <span>email varchar(128) not null, </span><span>20</span> <span>age tinyint unsigned not null);</span><span>*/</span> <span>21</span> <span>22</span> <span>/*</span><span>插入数据 </span><span>23</span> <span> insert into user1(name,password,email,age) </span><span>24</span> <span> values('daomul',md5('daomul'),'975052664@qq.com','22'); </span><span>25</span> <span>*/</span> <span>26</span> <span>27</span> <span>/*</span><span>查询数据 </span><span>28</span> <span> select * from user1; </span><span>29</span> <span>*/</span> <span>30</span> <span>31</span> <span>/*</span><span>输入中文的问题解决 </span><span>32</span> <span> set character_set_client-gbk; </span><span>33</span> <span> set character_set_result-gbk; </span><span>34</span> <span>35</span> <span> #显示所有字符类型 :show variables like '%char%'; </span><span>36</span> <span>37</span> <span>*/</span>
1、查询一行数据
"select name from user1 where age=' " .$age. " ' limit 0,1;" //控制在0-1条数据
2、模糊查询
"select name from user1 where email like ' % " $email " %' ";
3、批量执行 sql语句
3.1 批量执行dml语句
(1 $sql="$sql1;$sql; ....";
或者 :$sqls="" ; $sqls.=""; $sqls.=""; ....
(2 mysqli::multi_query($sqls); //执行操作,并返回 操作的数目。
3.2 批量执行dml语句
具体事例:见 http://www.cnblogs.com/daomul/p/3381782.html
4、自我复制:测试高度的数据
insert into emp(name,grade,email,school,salary,remark)select name,grade,email,school,salary,remark from emp;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

不同数据库系统添加列的语法为:MySQL:ALTER TABLE table_name ADD column_name data_type;PostgreSQL:ALTER TABLE table_name ADD COLUMN column_name data_type;Oracle:ALTER TABLE table_name ADD (column_name data_type);SQL Server:ALTER TABLE table_name ADD column_name data_
