Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A brief Analysis of the related Operation and call of Mysql

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the related operation and call analysis of Mysql, the content of the article is carefully selected and edited by the author, and the related operation and call analysis of Mysql has certain pertinence, which is of great significance to everyone's reference, so let's learn about the next topic with the author.

1. Enter Mysql, database, and related operations

1.Mysql: mysql-uroot-p

two。 Check out the library: show databases

3. Create Library: create database Library name

Craete database library name default charset utf8

4. View the library structure: show creata database library name

5. Delete Library: drop database

6. Enter the library: use library name

7. Create table: creata table table name (field value field value constraint condition

Field value constraint condition

.

Field value constraints)

8. Delete table: drop table table name

9. View table editing method: show create table table name

10. Delete table: drop table table name

11. View table fields: desc table name

II. Additions, deletions, modifications and queries of the database

1. Increase

1.insert into table name (field name, field name,...) value (field value, field value,...)

2.insert into table name (field name, field name,...) value (field value, field value,...)

Value (field value, field value,...)

2. Delete

1.delete from table name where field name = 'field value'

2.delete from table name; / / only the contents of the table can be deleted, and the table is still there.

3. Change

1.update table name set target field name = 'new field value' where conditional field name = 'conditional field value'

4. Check

1. Full table query: select * from table name

two。 Query item by item: select * from table name\ G

3. View the number of records in the table: select count (field name) from table name

4. View specific fields: select field name, field name,... from table name

5. Query by condition: select*from table name where (not) (field name = 'field value' or/and field name = 'field value'

Or/and field value = 'field name'.)

6. Fuzzy query: select*from table name where field name like "% search key%"

7. Query in reverse order: select*from table name order by field name desc

8. Group query: select field name, count (field name) from table name group by field name

9. Several queries: select*from table name limit starting query value-1, number of queries

10. Combined query: select*from table name where group by / order by limit starting query value-1, number of queries

3. Call Mysql

1. Link database (5 values: database address, user name, user password, database, port number)

$conn=mysqli_connect ('locallhost','root',' password', 'database', 3306)

two。 Spelling sql statement

A. $sql= "insert into table name (field name, field name,) value ('field value', 'field value',...)"

Var_dump ($sql)

B. $sql=select*from table name where field = 'field value' and field = 'field value' and field = 'field value'.

3. Execute sql statement

Mysqli_query ($conn,'SET NAMES UTF8')

$re=mysqli_query ($conn.$sql)

After reading the above analysis of Mysql-related operations and calls, many readers must have some understanding. If you need more industry knowledge and information, you can continue to pay attention to our industry information column.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report