FAQ Database Discussion Community


insert data from 3 tables with the same fields into 1 table

mysql,sql,insert,insert-into
I have 3 tables (accnt, jobcost, and servic15). all with the same fields (code, jno, ven, date). I need to insert the data from these tables into another table called dummy with the same fields, in one query. how do I do this? i have used 3 separate insert into...

ZF2 Bulk insert using INSERT INTO … SELECT from a table to same table

php,zend-framework2,bulkinsert,insert-into
I am trying to do a bulk copy of some records from a table into the same table with one field changed. But I am not able to find the correct method in ZF2 for it. My existing table looks like this : CoID -- CatCode -- CategoryName PP --...

SQL INSERT INTO WITH SELECT query

sql,sql-server,select,insert-into
Not being experienced with SQL, I was hoping someone could help me with this. I have a empty temp table, as well as a table with information in it. My outline of my query as it stands is as follows: CREATE TABLE [#Temp] (ID Int, Field1 Varchar) INSERT INTO [#Temp]...

MySQL INSERT INTO with PHP $variable

php,mysql,variables,insert-into
I can use $variable there $strSQL = "SELECT * FROM $person"; But I can't use $variable there $sql = "INSERT INTO $person . . . `$person` Don't working too... What the difference? And how I can use $variable instead of name of the table (INSERT INTO table_name) $sql = 'INSERT...

This query runs perfectly in Access 2010 but when I try to execute it in my code I get Syntax error in INSERT INTO statement

sql,vb.net,ms-access,oledb,insert-into
I am a newby programmer and I have had a look at other posts similar to this and they say that the problem is usually due to reserved words being used, however I am sure that I am not using any. The sql runs fine in access and creates the...

MySQL INSERT shorthand vs longhand performance [closed]

mysql,database,performance,query-performance,insert-into
What is the difference between: INSERT INTO `table_name` SET `col1` = 'val1', `col2` = 'val2', `col3` = 'val3' and INSERT INTO `table_name` (`col1`,`col2`,`col3`) VALUES('val1','val2','val3') Is there a performance benefit of using shorthand? I prefer longhand myself, but logically, for performance reasons, should I be using shorthand every time? Benchmark testing...

Insert into w/ multiple selects giving ERROR 1242: Subquery returns more than 1 row

insert-into,mysql-error-1242
I have table foo1 with columns UserID,TimeStamp; foo2 with columns userID,Level & table foo3 with columns userID,Timestamp. I want to INSERT into foo1 all rows from foo3 where the UserID exists in table foo2. I am getting ERROR 1242: Subquery returns more than 1 row with the following INSERT into...

php mysql select insert on different DBs in same server

php,mysql,insert-into
I have two DBs on the same server. Table1 in db1 has 11 columns, and around 8 million rows of data. I want to insert four columns' worth of table1 data (i.e., 4 columns x 8 million rows) into table2 in db2. I tried this using php in the script...

Insert into query is not working php [closed]

php,mysql,database,insert-into,isqlquery
$sql = "INSERT INTO `Visitors`(`Cust_id`, `first_name`, `last_name`, `Email_address`, `Phone_no`, `St_Addr`, `city`, `State`, `zip`, `age`, `Ethnicity`, `Signup_Date`) VALUES (".'$firstname'.", ".'$lastname'.", ".'$email'.", ".'$telephone'.", ".'$Street_Address'.", ".'$City'.", ".'$State'.",".'$ZIP'.",".' $age'." , ".'$Ethnicity'.",".'$date'.")"; Id is on auto increment...

MySQL Error 1064 (42000) Script Insert

mysql,mysql-error-1064,insert-into
I receive an error for any insert statement I put after load data. I have tried rearranging the insert statements but still received errors. Not sure what to do, any help would be awesome! The error is: Error: "Error 1064 (42000): ... right syntax to use near '--Load data Insert...

MYSQL INSERT INTO ERROR

mysql,insert-into
i keep getting error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."LTTA3101","1","03-JAN-07"), ("SK3127","LTCPF502","5","03-JAN-07")' at line 17 INSERT INTO sales (cust_id,prod_id,quanitity,date_of_sale) values ("MH3367 ","DTHP7710","1","01-OCT-06"), ("GM4632","DTCP2109","4","08-OCT-06"), ("GM2581","LTTA3101","1","10-OCT-06"), ("GM4632","LTCPF502","2","28-0CT-06"), ("KM4673","LTCPC505","4","04-NOV-06"), ("MH3367","LTPBMZ36","3","22-NOV-06 "),...

SQLite INSERT with SELECT

sqlite,insert,insert-into
I have a problem with INSERT Query. I want to insert some fixed values as a name but as well some calculated values. A simple example: INSERT INTO Players VALUES('Name', 10.0, SELECT COUNT(*) AS Amount FROM Stack7 WHERE Name LIKE '%Name%', 1.0) Table Players: CREATE TABLE `Players` ( `Name` TEXT,...