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

Common operations of navicat,mysql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Mysql updates a field in the table, intercepts the value of the field and saves it.

Navicat A shortcut to copy all the fields in a table

Pgsql-or mysql

Sometimes you need to copy all the fields in a table to spell the list of sql fields, and you also need to connect them with commas. Sql can be used to check: 1. This is a list of fields connected by commas: select group_concat (COLUMN_NAME) from information_schema.COLUMNS where table_name = 'table name'; 2. The fields are displayed directly, and the SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE table_name=' table name 'and TABLE_SCHEMA=' database name' is not written in the blue mark.

The use of insert into select from in mysql

How to combine fields from multiple tables and insert them into a new table in mysql is achieved through a sql statement. The specific situation is that there are three tables a, b, c, and now you need to check the values of several fields from table b and table c and insert them into the corresponding fields in table a. In this case, we can use the following statement to achieve this:

INSERT INTO db1_name (field1,field2) SELECT field1,field2 FROM db2_name

Of course, the above statement is more suitable for inserting data between two tables, but it is not suitable for multiple tables. For multiple tables, we can first join the fields that need to be queried, and then form a view and then select from:

INSERT INTO a (field1,field2) SELECT * FROM (SELECT F1 FROM b JOIN c f2) AS tb where F1 is the field of table b, f2 is the field of table c, the fields from table b and table c are combined by join query, and then inserted into table a by select nested query, which satisfies our scenario. If you need more than 2 tables, you can combine fields in the form of multiple join. It should be noted that the nested query section must have a setting table alias at the end, as follows: SELECT * FROM (SELECT f1 FROM b JOIN c f2 FROM b JOIN c) AS tb that is, the last as tb is necessary (of course, the name tb can be taken at will), that is, specify an alias, otherwise the following error will be reported in mysql: ERROR 1248 (42000): Every derived TABLE must have its own alias means that each derived new table must specify an alias.

Associate 2 fields,:

.

When will union be allowed?

Answer: it can be used as long as the two result sets have the same number of columns, even if the field types are different.

Https://blog.csdn.net/yuxin6866/article/details/52190772

Mongo data is moved to mysql:

Note that the'_ id', df from_dict format and engine coding are removed from the dict.

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