insert

php mysql_insert_id on multiple rows?

Hi, Is it possible to get the auto incremented ids from a query which inserts multiple rows? eg: INSERT INTO table (col1, col2) VALUES (1, 2), (3, 4), (5, 6); Alteratively, is there a way to find the NEXT auto increment value WITHOUT inserting anything into the table? Thanks ...

jquery insert html into list before a child ul-tag

Hello I have this: <ul id="pickme"> <li>1</li> <li>2</li> <li>3 <ul> <li>3-1</li> </ul> </li> </ul> But want this: <ul id="pickme"> <li>1</li> <li>2</li> <li>3</li> <li class="new_ul"> <ul> <li>3-1</li> </ul> </li> </ul> With other words I need to ...

LINQtoSQL: What is the best way to check if a row exists on insert?

Hi, I'm doing updates from Excel/CSV files to a database. I'm using LINQ to SQL for database operations. I have quite a few columns to update/insert, so I guess it would be easier to generate a Checksum somehow for the whole row. For example I can have the same person [firstname,lastname,ssn,address] in the destination table, BUT sent ...

create/append node vs innerHTML

Does anyone have a good reason to use one over the other? As far as I can tell, create/append node simply prevents you from creating invalid code, while innerHTML allows you to inject multiple nodes at once. Given that I need to insert several tags, it seems to make sense to use innerHTML. Does anyone have a different take? ...

MySQL INSERT INTO / ON DUPLICATE KEY with SELECT statement issue

Howdy - I'm a MySQL Noob. I have a table of various business listings and I am trying to populate a second table called cities that contains unique city names along with a count of how many listings per city. I'm able to do a SELECT statement that gets me this data fine like so: SELECT city,state,sum(count) FROM ( SELECT city,state, 1 A...

Example using OpenXML with Parent Child Relationship and Associated Lookup Tables

I have an XML document that is loaded into a column of a table of the XML data type. Is there any good examples showing how to insert using a store procedure and OpenXML into a parent tables with primary key and also into a child table with it's associated foreign key? Both the Parent and Child have relationships to lookup tables. The ...

Insert value into SQL Server

I want to insert value into SQL Server but there is problem is I pass both value in parameter then it's not insert otherewise if i selecting one value then it's insert my database name is sample and table is item this is perfect insert statement or not ? try { int val = stmt.executeUpdate("INSERT item (patientid,itemid) VALUES(nPat...

Possible latest Branch Merge Insert Datetime Bug

I ran into a bug with version 3.0.0.3 and the linq templates. The one where Update was a null object. So I downloaded the latest source for Subsonic.Core from git (merge branch from eibrahim Nov 3 2009). I built the source and am using the latest dll in my project. It has fixed the problem with running Update queries but now I have anoth...

Using uniqueidentifier as Primary Key and inserting it from the client application using parameterized queries.

I have created a database where I use uniqueidentifier as the primary key. I'm trying to run a parametrized query that in the end looks like this. (insert into someTable (uniqueID) Values('76c14693-5475-4224-ba94-7d30c919ac59') (uniqueID is my PK). This insert statement executes without issues when I run it in SQL Server Management Stu...

XML and Inserting into Parent Child tables with Related Lookup Tables

The FuelPathwayCode and PhysicalPathwayCode go into Parent table and transaction-item elements goes into the Child table. Parent table has a primary key and the child table has the related foreign key. The Parent table has FuelNameID and PhysicalPathwayID columns that are related to two lookup tables: FuelName and PhysicalPathway. Th...

mySQL - Insert into three tables

I recently asked this question. I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after. Is it possible with a single query to query an id in the first table which g...

mySQL - Prevent double booking

I am trying to work out the best way to stop double 'booking' in my application. I have a table of unique id's each can be sold only once. My current idea is to use a transaction to check if the chosen products are available, if they are then insert into a 'status' column that it is 'reserved' along with inserting a 'time of update' th...

Help with insert trigger

hey i have a temp table (question_desc, ans1, ans2, ans3, ans4, correct_ans, marks) with say 10 entries from this table i have to insert values in two other tables questions (q_id(auto-generated), que_desc, marks) answers (ans_id(auto_generated), q_id(FK), ans_desc, istrue) for each insert in question table there should be four inse...

How can I insert data without specifying a value for a non auto-increment primary key?

I have this table: CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) ) 1. insert into persons values (1, 'John', 'Smith', 'LA', 'LA'); 2. insert into persons (p_id, lastname, firstname, address, city) values (2, 'John', 'Smith'...

mySQL - Table locking vs Row locking

Application Description I have a table which stores id's which represent area's on a map. Each map contains 1000 areas. A territory is any number of area's of a map that are touching. Users fight for ownership of different areas of the map. Database Design Currently I have a table of maps, a table of territories and a table of areas....

iphone core data inserting new objects question

Hi, I have been reading through the core data documentation and feel I am still missing something. I do not quite understand how you insert objects into a relationship of another object. For example the following two Entities are in my model flightDepartureBoard name: from_airport: to_airport: current_flights: (this is a one to ...

Copy mdf file and use it in run time

After I copy mdf file (and his log file) I tries to Insert data. I receive the following message: "An attempt to attach an auto-named database for file [fileName].mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. When I copied the file manual everything worked normally....

LINQ to SQL - retrieve object, modify, SubmitChanges() creates new objects

I've been battling this for a while. I'm trying to implement a many to one association. I have a bunch of rows in a table, called readings. These accumulate over time, and every now and then I want to export them. When I export them I want to create a new object called ExportEvent, to track which rows were exported, so they can be re-exp...

SQL Copy Row for a list, change one column value

I need to duplicate a row a couple thousand times. I need to change one column from the copied row based on a list of ids. Psuedo-code: INSERT INTO MyTable (TabID, Other Columns) VALUES (TabID = (SELECT TabID FROM OtherTable WHERE ParentID = 1), Other Columns) Is this doable? ...

Automatically match columns in INSERT INTO ... SELECT ... FROM ...

Hi! SQL Server question. When doing INSERT INTO T1 SELECT (C1, C2) FROM T2 I don't want to specify column names of T1 because they are the same as in T2 Is it possible to do so? Currently I'm getting error Msg 213, Level 16, State 1, Line 1 Column name or number of supplied values does not match table definition. ...