What is the multi-table joint query statement in mysql

The multi-table joint query statement in mysql is: [select statement 1 union [union option] select statement 2 union [union option] select statement n]. The result of multi-table joint query is to combine the query results of multiple select statements. 【Related learning recommendation: mysql tutorial(video)】 Mysql multi-table joint query statement is: The joint query result is to combine the query results of multiple select statements together. You can use the union and union all keywords to merge. Basic syntax: select statement 1 union [union option] select statement 2 union [union option] select statement n The union option has two options: all (repeat and output); distinct (deduplication , completely repeated, will be deduplicated by default) The fields of the two tables should be the same. Example: select id,addrid from addr union all select id,addrid from student The meaning of joint query 1. Query the same table, but the requirements are different 2. Multi-table query: The structure of multiple tables is exactly the same, and the saved data (structure) is also the same Use of joint query order by In joint query: order by can only use one last, Parentheses are required for query statements. Example: —(mistake) select * from student where sex=”man”…

How does mysql view user permissions

How to view user privileges in mysql: 1. To view the privileges of a MySQL user, the syntax is [show grants for user name]; 2. To use the authorization method of the database, the code is [GRANT ON ..]. 【Related learning recommendation: mysql tutorial(video)】 How to check the permissions of the user table in mysql: (1) Check the permissions of a MySQL user: show grants for username MariaDB [neutron]> show grants for root; (2) Use the GRANT command to create new users, set user passwords, and increase user rights. The format is as follows: mysql> GRANT ON TO [IDENTIFIED BY “”] [ WITH GRANT OPTION]; Example: GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@& #39;localhost'IDENTIFIED BY'NEUTRON_DBPASS'; GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS'; neutron.* : Indicates all tables in the neutron database, and the neutron library must be created before authorization. If *.* means all tables of all libraries & # 39; neutron & # 39; @ & # 39; localhost & # 39; : Indicates the created user name neutron, followed by @ indicates the client that is allowed to access the data, ‘localhost’ indicates the local machine, ‘%’ indicates all hosts [IDENTIFIED BY “”]: set neutron…

How to use MySQL foreign key

Methods of using MySQL external keys: 1. The two tables must be InnoDB table types; 2. The domain used in the foreign key relationship must be an index type Index; 3. The domain used in the foreign key relationship must be of the same data type resemblance. 【Related learning recommendation: mysql tutorial(video)】 Methods of using MySQL external keys: 1. Only InnoDB tables can use foreign keys. Mysql defaults to MyISAM, which does not support foreign key constraints 2. The benefits of foreign keys: it can make two tables associated, ensure data consistency and realize some cascading operations. 3. The role of foreign keys: To maintain data consistency and integrity, the main purpose is to control the data stored in foreign key tables. To associate two tables, the foreign key can only refer to the values ​​of the columns in the foreign table. 4. The prerequisite for establishing a foreign key: The two tables must be of the InnoDB table type. The field used in the foreign key relationship must be an index type (Index). The field used in the foreign key relationship must be similar to the data type. 5. Steps of creation Specify the primary key keyword: foreign key…

How to modify the MySQL field to capitalize the first letter

The method of modifying the first letter of the MySQL field: first use LEFT to take out the first letter alone and use UPPER to replace it with uppercase; then determine the length of the field, and use SBUSTRING to take out all the fields from the second to the end for backup; then Use CONCAT to connect the two values ​​above; finally, modify the value of the update table field. The above is the detailed content of how to modify the MySQL field to capitalize the first letter. For more information, please pay attention to other related articles on 1024programmer.com!

How to deal with 1045 error in mysql database

The solution to the 1045 error in the mysql database: first find the [my.ini] file under the MySQL installation path, and open it with Notepad; then find the location of mysqld; then add the statement [skip] under [mysqld] -grant-tables]; save it at last. The above is the detailed content of how to deal with the 1045 error in the mysql database. For more information, please pay attention to other related articles on 1024programmer.com!

How does mysql change the connection port

How to change the connection port of mysql: first log in to mysql; then use the command [show global variables like & # 39; port & # 39;;] to check the port number; then modify the port; finally restart mysql. 【Related learning recommendation: mysql tutorial(video)】 How to change the connection port of mysql: 1. Log in to mysql mysql -u root -p //Enter the password 2. Use the command show global variables like 'port'; to view the port number mysql> show global variables like 'port'; 3. Modify the port Edit /etc/my.cnf file, earlier version It may be the name of the my.conf file, add the port parameter, and set the port, note that the port is not used, save and exit. [root@test etc]# vi my.cnf [mysqld] port=3506 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid “my.cnf” 11L, 261C written [root@test etc]# 4. Restart mysql [root@test ~]# /etc/init.d/ mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ] For more programming learning, please pay attention to the PHP training column! The above is the detailed content of how mysql changes the connection port. For more information, please pay attention to…

Interacting with MySQL database through PDO extension to realize adding, deleting, modifying and querying and database transactions

Related learning recommendation: mysql tutorial Add, delete, modify and query through prepared statements Why use prepared statements We have briefly introduced the prepared statement in the previous tutorial. We can compare it with the view template. The so-called prepared statement is a predefined SQL statement template, and the specific parameter values ​​​​are replaced by placeholders. : INSERT INTO REGISTRY (name, value) VALUES (?, ?) INSERT INTO REGISTRY (name, value) VALUES (:name, :value) Then bind the specific parameter value with the corresponding placeholder through a specific API method before actually executing the SQL statement and mapping. It’s as if the defined view template also replaces the variable with a specific placeholder, and then passes the variable value in to fill and render when it is actually rendered. Why take all this trouble? Wouldn’t it be nice to directly use the query method demonstrated earlier to add, delete, modify, and check? Uh, then let’s talk about the benefits of prepared statements, or why use prepared statements for database interaction. There are two advantages: First, use prepared statements to define in advance The SQL template will only be parsed once, but it can be executed multiple times by passing different parameter values, thereby…

Where is the lib file of mysql

Where is the lib file of mysql

mysql php Write your review! Spit it out, see everything Member Login | User Registration recommended reading char MySQL InnoDB four transaction levels and dirty read, non-repeated read, phantom read_MySQL MySQLInnoDB transaction isolation level dirty read, repeatable read, phantom read MySQLInnoDB transaction isolation level has four levels, the default is repeatable read (REPEATABLE READ). · Read uncommitted (READUNCOM… [detailed] Crayon Shinchan 2023-08-26 13:36:59 char zabbix introduction and installation Introduction: The article is divided into 3 paragraphs 1. Zabbix introduction, including architecture, component workflow, etc. 2.zabbix installation, yum installation and compilation installation 3.zabbix… [detailed] Crayon Shinchan 2023-08-26 13:29:24

How to use enumeration type in mysql

How to use the enumeration type in mysql: 1. Insert data, the syntax is [insert into my_enum values ​​(1), (2);]; 2. Error data, the syntax is [insert into my_enum values( & # 39; male & # 39;);]. Related learning recommendation: mysql tutorial How to use the enumeration type in mysql: Enumeration: enum, to achieve all possible results are designed, in fact, the stored data must be one of the specified data. How to use enumeration Definition: enum (list of possible elements); such as enum (‘male’ ,’female’) Use: store data, only the data defined above can be stored The meaning lies in: 1, the possibility of limiting the value! 2, fast, faster than ordinary strings! The reason is that the enumeration type is managed by integers, which can be managed by 2 bytes! Each value is an integer identifier, starting from the first option as 1, increasing one by one! Management in the form of integers, faster than strings! There are 2 bytes in total, 0-65535, so there are 65535 options available! 、 Create enumeration table create table my_enum( gender enum(‘Male’, ‘Male’, ‘Female’, ‘Confidential’) )charset utf8; The first function: standardize the data format, the data can only be one of the…

How does mysql verify whether the installation is successful

How to verify whether mysql is successfully installed: 1. Open the DOS window, enter the status command to view the MySQL version information; 2. Open the MySQL 5.7 Command Line Client program, open the current MySQL server status, and enter the relevant command to display the current MySQL server status. list of databases. The above is the detailed content of how to verify whether mysql is successfully installed. For more information, please pay attention to other related articles on 1024programmer.com!

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索