I have a very large table called paypal_ipn_orders
. In this table I have 2 important bits of information a row called item_name
and a row called sort_num
. I want to use certain parameters to pull out records from paypal_ipn_orders
and put them into a temporary table called temp_table
. I know how to select the records as follows
我有一个很大的表,叫做paypal_ipn_orders。在这个表中,我有两个重要的信息位:一个是item_name,另一个是sort_num。我希望使用某些参数从paypal_ipn_orders中提取记录,并将它们放入名为temp_table的临时表中。我知道如何选择记录如下
SELECT `item_name`, `sort_num`
FROM `paypal_ipn_orders`
WHERE `packing_slip_printed` = 0
AND LOWER(`payment_status`) = `completed`
AND `address_name` <> ''
That query selects all the records I want to move to the temporary database I just don't know how to do that.
这个查询选择我想要移动到临时数据库的所有记录,我只是不知道怎么做。
1 个解决方案
#1
3
Use MySQL's Insert Into Select I added generic data types to the columns in the temp table, you'll want to find out what the actual data types are from your table and make them the same.
使用MySQL的Insert Into Select I向temp表中的列添加了通用数据类型,您将希望从表中找出实际的数据类型,并使它们相同。
CREATE TEMPORARY TABLE temp_table (
item_name varchar(50),
sort_num int
);
INSERT INTO temp_table (item_name, sort_num)
SELECT `item_name`, `sort_num`
FROM `paypal_ipn_orders`
WHERE `packing_slip_printed` = 0
AND LOWER(`payment_status`) = `completed`
AND `address_name` <> ''
#1
3
Use MySQL's Insert Into Select I added generic data types to the columns in the temp table, you'll want to find out what the actual data types are from your table and make them the same.
使用MySQL的Insert Into Select I向temp表中的列添加了通用数据类型,您将希望从表中找出实际的数据类型,并使它们相同。
CREATE TEMPORARY TABLE temp_table (
item_name varchar(50),
sort_num int
);
INSERT INTO temp_table (item_name, sort_num)
SELECT `item_name`, `sort_num`
FROM `paypal_ipn_orders`
WHERE `packing_slip_printed` = 0
AND LOWER(`payment_status`) = `completed`
AND `address_name` <> ''