如何在另一个表中存储MySQL查询结果?

时间:2021-05-29 15:45:17

How to store results from following query into another table. Considering there is an appropriate table already created.

如何将后续查询的结果存储到另一个表中。考虑到已经创建了适当的表。

SELECT labels.label,shortabstracts.ShortAbstract,images.LinkToImage,types.Type
FROM ner.images,ner.labels,ner.shortabstracts,ner.types
WHERE
  labels.Resource=images.Resource
  AND labels.Resource=shortabstracts.Resource
  AND labels.Resource=types.Resource;

4 个解决方案

#1


37  

You can use the INSERT INTO TABLE SELECT....syntax:

您可以使用插入表选择....语法:

INSERT INTO new_table_name
SELECT labels.label,shortabstracts.ShortAbstract,images.LinkToImage,types.Type 
FROM ner.images,ner.labels,ner.shortabstracts,ner.types 
WHERE labels.Resource=images.Resource AND labels.Resource=shortabstracts.Resource 
AND labels.Resource=types.Resource;

#2


75  

if the table doesn't exist (and you e.g. don't want to create it because it may have lots of column names) you can create it on the fly...

如果表不存在(而您不想创建它,因为它可能有很多列名称),您可以在动态中创建它……

CREATE TABLE another_table SELECT /your query goes here/

创建表another_table SELECT /您的查询转到这里

#3


6  

INSERT INTO another_table SELECT /*your query goes here*/

#4


5  

if your table dosen't exist then

如果你的桌子不存在的话

CREATE TABLE new_table SELECT //write your query here

if your table exist then you can just insert query

如果您的表存在,那么您只需插入查询

INSERT INTO new_table SELECT //write your query here

For more check here and here

这里和这里有更多的检查

#1


37  

You can use the INSERT INTO TABLE SELECT....syntax:

您可以使用插入表选择....语法:

INSERT INTO new_table_name
SELECT labels.label,shortabstracts.ShortAbstract,images.LinkToImage,types.Type 
FROM ner.images,ner.labels,ner.shortabstracts,ner.types 
WHERE labels.Resource=images.Resource AND labels.Resource=shortabstracts.Resource 
AND labels.Resource=types.Resource;

#2


75  

if the table doesn't exist (and you e.g. don't want to create it because it may have lots of column names) you can create it on the fly...

如果表不存在(而您不想创建它,因为它可能有很多列名称),您可以在动态中创建它……

CREATE TABLE another_table SELECT /your query goes here/

创建表another_table SELECT /您的查询转到这里

#3


6  

INSERT INTO another_table SELECT /*your query goes here*/

#4


5  

if your table dosen't exist then

如果你的桌子不存在的话

CREATE TABLE new_table SELECT //write your query here

if your table exist then you can just insert query

如果您的表存在,那么您只需插入查询

INSERT INTO new_table SELECT //write your query here

For more check here and here

这里和这里有更多的检查