将Blob内容插入另一个Blob(MySQL)

时间:2022-09-23 08:29:41
while($get_orange = mysql_fetch_assoc($select_image)){
$orange = $get_orange['image'];
$insert_test = mysql_query("INSERT INTO `image_test` (`id`,`image`) VALUES ('','".$orange."'");
}

How would I do this? The variable orange is the blob content, and I am trying to insert this blob content into another blob of a different table. If this is possible, how would I do this? I am in need of this for many features of my website.

我该怎么办?变量orange是blob内容,我试图将此blob内容插入到另一个表的另一个blob中。如果可以的话,我该怎么做?对于我网站的许多功能,我需要这个。

1 个解决方案

#1


0  

You can do this with a single query that combines selecting from one table with inserting into another:

您可以使用单个查询来执行此操作,该查询将从一个表中选择并插入到另一个表中:

INSERT INTO `image_test` (`id`, `image`) SELECT '', `image` FROM `images`;

You didn't show your original SELECT query, so I'm guessing a bit. The above query will insert all rows from images into image_test. You can add WHERE conditions as needed.

你没有显示你原来的SELECT查询,所以我猜了一下。上面的查询会将图像中的所有行插入到image_test中。您可以根据需要添加WHERE条件。

#1


0  

You can do this with a single query that combines selecting from one table with inserting into another:

您可以使用单个查询来执行此操作,该查询将从一个表中选择并插入到另一个表中:

INSERT INTO `image_test` (`id`, `image`) SELECT '', `image` FROM `images`;

You didn't show your original SELECT query, so I'm guessing a bit. The above query will insert all rows from images into image_test. You can add WHERE conditions as needed.

你没有显示你原来的SELECT查询,所以我猜了一下。上面的查询会将图像中的所有行插入到image_test中。您可以根据需要添加WHERE条件。