Let's say I hava a table
object:
id, primary key auto-increment
obj_id, foreign key (object.id)
val, integer
Is it possible to insert a record with obj_id = id. Not having an error with foreign key constraint?
Insert into object (val) values (123)
...
How would i insert a number of rows into a table given an incremental range, with one column of the row containing the values?
...
Basically, I want to insert if a given entry (by its primary key id) doesn't exist, and otherwise update if it does. What might be the best way to do this?
...
Hi,
is it possible to explicity insert values in timestamp column of DB2? For example i have a date time value '2\11\2005 4:59:36 PM'. How to convert it to timestamp value in DB2?
Thanks in advance
...
hi folks,
i'm trying to do something like this in postgres:
UPDATE table1 SET (col1, col2) = (SELECT col2, col3 FROM othertable WHERE othertable.col1 = 123);
INSERT INTO table1 (col1, col2) VALUES (SELECT col1, col2 FROM othertable)
but point 1 is not possible even with postgres 9.0 as mentioned in the docs (http://www.postgresql.or...
I created a method and pass the element type, id, and any inner text that instantiates a new html element. The last statement: Me.Controls.Add(element) adds it to the end of the page, but I would like it to be inserted in a specific position (between 2 divs within a form). What I am describing is very similar to this post on SO here, alt...
Ok I have been using PHP + MySQL for a while so I consider myself proficient. I have made my fair share of syntactical mistakes in the past but this is honestly pissing me off:
http://img251.imageshack.us/img251/3760/fubar.png
If anyone can tell me why this simple statement isn't working I would be greatly appreciative.
...
Hello, I'm working on a project that needs to be able to have JComponents inserted into a JTextPane, along with normal text. Currently, I'm using JTextPane.insertComponent(Component) to add the JComponents, however, they seem to be added sporadically with no real organization. I finally figured out that it's inserting it wherever the car...
I'm doing an INSERT ... ON DUPLICATE KEY UPDATE for a PRIMARY KEY in the following table:
mysql> describe users_interests;
+------------+---------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------------------+------+...
im using mysql, these are two tables i have:
posts {id, user_id, post, date}
post_tags {id, tag, post_id(references id in post), user_id}
what im trying to do is if the post has a #tag , i insert the intial post in the POSTS table, and the data in the post_tags table, how could i do that simlateanously?
P.S. i already know how to che...
Hello. Does anyone know what would be more efficient and use less resources:
Method 1-- Using a single SELECT statement to get data from one table and then iterating through it to execute multiple UPDATEs on another table. E.G. (pseudo-code, execute() runs query):
Query1_resultset = execute("SELECT item_id, sum(views) as view_count F...
I am creating a INSERT script and I am coming across a problem. There is a middle initial field that is a char(1)
Sometimes the records don't have anything in that field so I put a NULL. This causes a Data too long for column error. I don't want to just put ' ' as that leaves just a blanks space.
Is there another way around this?
...
In MS Access, I want to insert a new column into the returned result of a select query. The new column has the same value for every row. For example, my select returns columns A, B and I want C to be the new column created by the select query:
A B C
----------
a1 b1 c
a2 b2 c
a3 b3 c
...
It seems like there should be a query for this, but I can't think of how to do it.
I've got a table with a composite primary key consisting of two fields I'd like to populate with data,
I can do an insert into from one table to fill up half the keys, but I want to fill up the other half with a set of constants (0, 3, 5, 6, 9) etc...
s...
I know that within a trigger - at least for SQL Server - one should never assume that the inserted table has just one row, which means SQL like this in a trigger is usually bad:
select @UserID = ID from inserted
But out of curiosity, can a set of INSERT statements ever result in an inserted table of more than one row? I know it's easy...
How can I insert special symbols like trademark into SQLite table? I have tried to use PRAGMA encoding = "UTF-16" with no effect :(
...
I have a stored procedure that takes a table name and writes out a series of INSERT statements, one for each row in the table. It's being used to provide sample, "real world" data for our test environment.
It works well but some of these sample rowsets are 10, 20k records. The stored proc writes them out using the PRINT statement and ...
Is there a way to recover the last generated auto_increment identifier generated by an insert when using Hibernate ?
I know from my php background that you can get this information by way of a function call like mysql_insert_id(). I'm operating in grails and using HQL to get a performance boost on some insert operations, but I need to ...
Hi,
I am trying to insert some copy-right information into the beginning of some source files. I know that using sed in the following way:
sed "1iSome copyrighted information." sample.txt
would insert the text "Some copyrighted information" to the beginning of sample.txt.
I need to insert text from a file to the beginning of sample...
I have a MySQL table ( members ) with six columns ( FirstName, LastName, Email, username, password, Key)
I need to insert a string into the Key column for the username admin
How would I go about doing this?
...