我需要PHP PDO和SQLITE3的帮助。我有像
这样的表设备CREATE TABLE device (
object_identifier integer PRIMARY KEY NOT NULL,
object_name varchar(1024),
vendor_name varchar(1024),
vendor_identifier integer,
model_name varchar(1024),
firmware_revision varchar(1024),
application_software_version varchar(1024),
protocol_version integer,
protocol_revision integer,
max_apdu_length_accepted integer,
apdu_timeout integer,
number_of_apdu_retries integer,
database_revision integer,
system_status integer,
protocol_object_types_supported varchar(65),
segmentation_supported integer,
protocol_services_supported varchar(65),
local_time varchar(32),
local_date varchar(32),
location varchar(1024),
object_list_num integer
);
我还有另一张表fan_coil_jebeni
CREATE TABLE fan_coil_jebeni (
object_identifier integer PRIMARY KEY NOT NULL,
object_name varchar(1024),
vendor_name varchar(1024),
);
我的问题是有没有有效的方法从设备中选择所有并插入到fan_coil_jebeni而不需要迭代通过游标(有一堆行要插入)?
答案 0 :(得分:4)
您可以使用insert ... select
insert into fan_coil_jebeni(a,b,c) select a,b,c from device
答案 1 :(得分:2)
这个怎么样:
INSERT INTO fan_coil_jebeni SELECT object_identifier, object_name, vendor_name FROM device;
答案 2 :(得分:1)
CREATE TABLE IF NOT EXISTS `table1` SELECT * FROM `table2`