insert-into

Rails 3.2 + MySQL: Error: Field 'created_at' doesn't have a default value: INSERT INTO

白昼怎懂夜的黑 提交于 2019-12-21 07:08:54
问题 I created a new migration, where is mentioned ... t.timestamps in the created table are added these two columns ... | created_at | datetime | NO (Null) | | NULL (Default) | | updated_at | datetime | NO (Null) | | NULL (Default) | ... When I want to create a new item, I always get the error message Mysql2::Error: Field 'created_at' doesn't have a default value: INSERT INTO `table_name` (`first_col`, `second_col`) VALUES ('a', 'b') Am I missing something? I sent this miniapp to a friend of mine

MySQL How do you INSERT INTO a table with a SELECT subquery returning multiple rows?

≯℡__Kan透↙ 提交于 2019-12-17 07:18:33
问题 MySQL How do you INSERT INTO a table with a SELECT subquery returning multiple rows? INSERT INTO Results ( People, names, ) VALUES ( ( SELECT d.id FROM Names f JOIN People d ON d.id = f.id ), ( "Henry" ), ); I WANT to populate the new table with all results returning from this subquery. How do I do this without getting a ERROR 1242 (21000): Subquery returns more than 1 row 回答1: INSERT INTO Results (People, names ) SELECT d.id, 'Henry' FROM Names f JOIN People d ON d.id = f.id Combine the

MySQL How do you INSERT INTO a table with a SELECT subquery returning multiple rows?

本秂侑毒 提交于 2019-12-17 07:18:07
问题 MySQL How do you INSERT INTO a table with a SELECT subquery returning multiple rows? INSERT INTO Results ( People, names, ) VALUES ( ( SELECT d.id FROM Names f JOIN People d ON d.id = f.id ), ( "Henry" ), ); I WANT to populate the new table with all results returning from this subquery. How do I do this without getting a ERROR 1242 (21000): Subquery returns more than 1 row 回答1: INSERT INTO Results (People, names ) SELECT d.id, 'Henry' FROM Names f JOIN People d ON d.id = f.id Combine the

MySQL INSERT INTO with PHP $variable

喜夏-厌秋 提交于 2019-12-14 03:54:48
问题 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 INTO $person (date, min, sec, count, temp, universal) VALUES("'.$date.'", "'.$min.'", "'.$sec.'", "'.$count.'", "'.$temp.'", "'.$universal.'")'; if(!mysql_query($sql)) {echo '<center><p><b>ERROR!</b></p></center>';} else

How to insert multiple row from textareas in MySQL

♀尐吖头ヾ 提交于 2019-12-13 09:08:55
问题 i cant insert to mysql from two textarea (both every row), first this is a add.html <form id="form1" name="form1" method="post" action="func/insert.php"> <table> <tr> <td>text 1</td> <td>:</td> <td><textarea class="custom" rows="10" cols="80" name="text1" id="text1" required></textarea> </td> </tr> <tr> <td>text 2</td> <td>:</td> <td><textarea class="custom" rows="10" cols="80" name="text2" id="text2" required> </textarea></td> </tr> </table> </from> and then insert.php <?php include

number of query values and destination fields are not the same

喜夏-厌秋 提交于 2019-12-13 01:58:57
问题 This is what I have for the Add Event. CurrentDb.Execute "INSERT INTO tblMatchBook ([Patron], [Staff], [TimeReceived], [SurveyLink], [DateFinished], [BookTitles]) " & _ " Values('" & Me.ddBarcode & "," & Me.ddStaff & "," & Me.txtRDate & "," & Me.txtLink & "," & "" & "," & "" & "')" I cannot figure out what is wrong. 回答1: insert into Main values (28494,1,False,'Buto-asma Sirop' , 'Buto-asma Sirop', 3.99 , 'Syrup', 'ispani', ' ', ' ',0, '1',4988 ) 来源: https://stackoverflow.com/questions

Maximum number of columns / values you can INSERT INTO a table - mysql

时光怂恿深爱的人放手 提交于 2019-12-12 22:17:55
问题 Does anybody know what's the maximum number of columns/values you can insert into a table (mysql)? I get an error for... IDK... 20 columns/values? (yes, #_of_col = #no_of_val) INSERT INTO comenzi (a,b,c,d,e,f,...) VALUES (1,2,3,4,5,6,...) 回答1: You can have more than 20 columns in a table so I don't think that is your problem. Most likely you have the wrong number of columns in your values list or one of your column names is a keyword. You said you've already checked that number of values is

How to insert data into database using PDO registry system? [duplicate]

柔情痞子 提交于 2019-12-12 05:16:07
问题 This question already has answers here : Can I mix MySQL APIs in PHP? (4 answers) Reference - What does this error mean in PHP? (35 answers) Closed 2 years ago . hello im trying to create a registration system that will insert data into my database. The page is all working correctly with the form and all but nothing happens after clicking the register button. this is the php code from the register page <?php INCLUDE "connect.php"; INCLUDE "errors.php"; session_start(); $_SESSION['message'] =

JAVA, SQL, insert into no-duplicates

谁都会走 提交于 2019-12-12 04:39:25
问题 I am trying to insert into a table without duplicates. I am using SQL derbyclient in Java. The code is not working (error with 'where not exists' ). Any idea? Connection connection = DriverManager.getConnection("jdbc:derby://localhost:1527/PetroleumDataStorageSystemDB;create=true"); PreparedStatement statement; int i = 1; int progress = 0; for (Refuel refuelList1 : refuelList) { progress = (i / refuelList.size()) * 100; String sql = "INSERT INTO refuel (id_tank, time, fuel_volume, " +

Python/MySQL “Insert into” with variables

被刻印的时光 ゝ 提交于 2019-12-12 03:44:29
问题 I have a problem with inserting new rows to the MySQL table. The name of the table will change, so it must be a variable and with that I have the most trouble. How can I change name of the table "second" with variable? Any idea? add_word = ("INSERT INTO second " "(name, surname) " "VALUES (%s, %s)") data_word = (name1, surname1) cursor.execute(add_word, data_word) 回答1: You do it like this: add_word = ("INSERT INTO {table} " "(name, surname) " "VALUES (%s, %s)") atable = 'second' data_word =