Questions tagged [insert-query]

A DML command that inserts new data into a recordset.

Syntax: Here is generic SQL syntax of INSERT INTO command to insert data into MySQL table:

INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN ); To insert string data types it is required to keep all the values into double or single quote, for example:- "value".

Source : TutorialSpoint.com

44 questions
24
votes
1 answer

Define Changeset for insert query in liquibase

I have two table as following : CREATE TABLE StudentMaster ( sId SERIAL, StudentName VARCHAR(50) ); CREATE TABLE StudentClassMap ( studnetId BIGINT UNSIGNED NOT NULL, studentClass VARCHAR(10), FOREIGN KEY (studnetId) REFERENCES…
unknown
  • 4,859
  • 10
  • 44
  • 62
7
votes
2 answers

Hibernate insert query

During insertion in hibernate query i'm passing some fields as table class objects which i've mapped to corresponding tables, The query works fine but the query is becoming too large because each of these mapped objects are getting updated…
Denny
  • 105
  • 1
  • 2
  • 7
6
votes
2 answers

How to write Insert Query in Yii2?

In Yii2 How to insert data from one table to another table. Here i have two tables table1 and table2. Now what i need is when a condition met i need transfer a specific data from table1 to table2. so help to write insert Query for this scenario in…
Kalai S
  • 986
  • 3
  • 14
  • 25
5
votes
2 answers

Insert new row with data computed from other rows

Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ | Id | Type | Value | +----+------+-------+ | 0 | A | 1 | | 0 | B | 1 | | 1 | A | 2 | | 1 | B | 3 | | 2 | A | 5 | | 2 |…
Tyler McHenry
  • 74,820
  • 18
  • 121
  • 166
4
votes
4 answers

PHP/MySQL Insert Query

For the life of me I can't get this insert query to work. mysql_connect("**host**", "**username**", "**password**") or error("Could not connect: ".mysql_error()); mysql_select_db("**db_name**"); $db = mysql_query("INSERT INTO `pass_reset`…
Spencer
  • 597
  • 2
  • 11
  • 19
4
votes
1 answer

format code appears twice error while inserting DATETIME from C# to Oracle DB

I am facing the below oracle error for the query Insert Query: INSERT INTO WINBACK_REFERRAL_CODES (REFERRAL_CODE, IS_DELETED, CREATED_BY, CREATED_DT, MODIFIED_BY, MODIFIED_DT, DELETED_BY, DELETED_DT) values ('sfsdfsd', 'N', …
user545359
  • 413
  • 5
  • 16
  • 29
3
votes
1 answer

How to use JPA Prepared statment for Insert query in java

I would like to know how to use prepared statement for insert query. Generally for select query I am using in following way. Query query = JPA.em() .createNativeQuery("select item_status from item_details where…
2
votes
4 answers

how to limit the amount of comments or replies to comments a user can post per day

I have a comment section and a reply to comment section on my social network. We are having some trouble with manual spammers, and I was going to limit the amount of comments someone could post a day. Here are the insert queries for comments and…
LightningWrist
  • 937
  • 4
  • 20
  • 37
1
vote
1 answer

Android show medias with old date on galery

I want to insert media in mediastore with a old date. Example ; val values = ContentValues() val extension = fileName.fileExtension() val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) values.apply { …
ahmetvefa53
  • 581
  • 6
  • 20
1
vote
1 answer

Prepared statements with Node-MSSQL

I want to store API data in a SQL Server database with Node.js. It works already with a normal INSERT query as you see in the first code below. server.route({ method: 'POST', path: '/', handler: async(request, h) => { …
1
vote
3 answers

PHP&MySQL: Is it possible after running mysql_query with an insert to get the ID of the new row?

Is there a straightforward way to run mysql_query with an insert and get the ID of the new row, for example in the return? Or will I have to do another query with select to check it?
fmsf
  • 36,317
  • 49
  • 147
  • 195
1
vote
2 answers

run update or insert query after select query mysql in php

i have spend more than 24 hours trying to run update or insert query after select query but select query done and update or insert query never done when submite "displayid" code## if($_POST["displayid"]==TRUE) { $sqlid = "SELECT * FROM doc1…
soma
  • 61
  • 1
  • 10
1
vote
1 answer

Inserting a time into mysql database in java

I want to insert a time which is taken from a textbox to the mysql database TIME column. I suppose I need to convert String to TIME like converting String to Date in mysql using "STR_TO_DATE" in the query. I looked for answers but I didn't get the…
Rukshan Mahendra
  • 113
  • 1
  • 1
  • 7
1
vote
1 answer

How to write custom insertQuery for HABTM( HasAndBelongsToMany ) relationship in Cakephp?

In my Cakephp application I have define HABTM relation between User Table ( /app/Model/User.php) and Group Table (/app/Model/Group.php ) on 'username'(of User Table) and 'group_id'(of Group Table). And the relation table is user_groups (…
1
vote
6 answers

Why SQL INSERT query takes the entered values as column names

I have a problem with the SQL INSERT QUERY. Whenever I execute the INSERT QUERY in the below code, what happens, is the query understands the values to be entered as the column names. My code is : try { Class.forName("com.mysql.jdbc.Driver"); …
Roshan George
  • 187
  • 2
  • 2
  • 13
1
2 3