Re: INSERT using SELECT results

2007-02-18 Thread Anoop kumar V
This may help you: mysql create table locais( - id int, - type varchar(2), - `desc` varchar(10)); Query OK, 0 rows affected (0.12 sec) mysql select * from locais; +--+--+---+ | id | type | desc | +--+--+---+ |1 | t1 | sk| |2 | t2 | dsk | |

Re: INSERT using SELECT results

2007-02-18 Thread Afan Pasalic
INSERT INTO ztipos (type) VALUES (SELECT DISTINCT type FROM locais) ? -afan Miguel Vaz wrote: Hi, I have a table LOCAIS with: idtypedesc 1t1blah blah 2t1uihuih 3t2pokpokp I want to list only the distinct types and create a

Re: insert into... select... duplicate key

2005-09-25 Thread Danny Stolle
Hi, I am hoping you meen this: You have to use the fields in your into -statement and select statement, not including the field having the auto-numbering so if e.g. field1 has autonumbering - insert into table1 (field2, field3) select (field2, field3) from table1; autonumbering will

RE: insert into... select... duplicate key

2005-09-25 Thread Schimmel LCpl Robert B \(GCE 2nd Intel Bn Web Master\)
That is the effect that I am looking for, but exactly the method that I am trying to avoid. If I type the column names into my INSERT... SELECT and someone later adds a column to the table, I would have to go back into my program and update the statement. I am looking for a way to do it

Re: insert into... select... duplicate key

2005-09-25 Thread Danny Stolle
Well I haven't realy found a select method in which you can isolate a field. Like a complementary method, in which you select like one field, but shows the fields except the field which you have used in your select-statement. So you excually want to dynamically insert the records, not knowing

RE: insert into... select... duplicate key

2005-09-25 Thread Schimmel LCpl Robert B \(GCE 2nd Intel Bn Web Master\)
I am using Cold Fusion and as I stated in my original message, if I were using MySQL 5, then I could use information_schema to retrieve the column names in the table and do it with variables in Cold Fusion. I do that on all my pages on the MySQL 5 servers with which I work. However, the server I

Re: insert into... select... duplicate key

2005-09-25 Thread Danny Stolle
I am not familiour with Cold Fusion but: cant you use 'show columns from table' ?? and use the result object? This normally works in e.g. C or PHP danny Schimmel LCpl Robert B (GCE 2nd Intel Bn Web Master) wrote: I am using Cold Fusion and as I stated in my original message, if I were

Re: insert into... select... duplicate key

2005-09-25 Thread Michael Stassen
Relevant bits of the conversation so far, with my thoughts at the end: Schimmel LCpl Robert B (GCE 2nd Intel Bn Web Master) wrote: Here is the problem that I am having. I am trying to make a copy of a full record in a table that has a primary key with auto-increment. The real problem is that I

RE: insert into... select... duplicate key

2005-09-25 Thread Schimmel LCpl Robert B \(GCE 2nd Intel Bn Web Master\)
Subject: Re: insert into... select... duplicate key Relevant bits of the conversation so far, with my thoughts at the end: Schimmel LCpl Robert B (GCE 2nd Intel Bn Web Master) wrote: Here is the problem that I am having. I am trying to make a copy of a full record in a table that has a primary key

Re: INSERT INTO ... SELECT

2004-04-01 Thread Egor Egorov
Ricardo Lopes [EMAIL PROTECTED] wrote: I have to copy some records from one table into the same table is it posible? my sql is like this: INSERT INTO equipamento_componentes (cod_equipamento_componentes, cod_tipo, numero, data_colocacao, cod_componente) SELECT '', 'C', 65, NOW(),

Re: INSERT INTO SELECT

2004-03-04 Thread Jacque Scott
OK, I found the answer. CREATE TABLE ProductSums SELECT DISTINCTROW IndenturedList.NSIPartNumber, Sum(tblInvTransaction.Qty) AS SumOfQty FROM IndenturedList;

RE: INSERT INTO () SELECT...

2002-11-21 Thread Jennifer Goodie
http://www.mysql.com/doc/en/INSERT_SELECT.html You cannot select from the table you are inserting into. Insert into a temp table and then insert into holds from that table. -Original Message- From: Eric [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 1:14 PM To: [EMAIL

Re: INSERT INTO () SELECT...

2002-11-21 Thread Mirza Muharemagic
Hi Eric, thats oracle function INSERT INTO ... SELECT. it doesn't work in mysql. Mirza [EMAIL PROTECTED] __ 21.11.2002 22:13 Hi, This should work, I think, but doesn't INSERT INTO holds (ord_num) SELECT orders.ord_num FROM orders

Re: INSERT INTO () SELECT...

2002-11-21 Thread Jocelyn Fournier
Hi, Yes it works, but you can't insert and select data from the same table with this syntax. Regards, Jocelyn - Original Message - From: Mirza Muharemagic [EMAIL PROTECTED] To: Eric [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, November 22, 2002 12:30 AM Subject: Re: INSERT

Re: INSERT INTO ... SELECT question

2002-11-14 Thread Greg Macek
Well, amazingly enough, it works great! I found a test box to try it on first before implementing this on the production box. This will definitely make life easier... On Thu, 2002-11-14 at 10:14, gerald_clark wrote: Did you try it? Did it work? Greg Macek wrote: Hello, I recently

Re: INSERT INTO ... SELECT question

2002-11-14 Thread Matthew Baranowski
Hey Greg: A slightly easier way to do this is to use a timestamp field. Timestamp is just a standard mysql data type. When a record is added, it records the current time. When a record is updated, the timestamp field will be set to the time of the update.

Re: INSERT INTO ... SELECT question

2002-11-14 Thread Greg Macek
Thanks for the tip! Looks like I can change my date_archived field to timestamp(8), since all I care about for this is the date information (actual time is useless to me). My sql query all of a sudden got a lot simpler. Thanks again for the help! On Thu, 2002-11-14 at 11:07, Matthew Baranowski

Re: INSERT INTO ... SELECT question

2002-11-14 Thread Paul DuBois
At 11:15 -0600 11/14/02, Greg Macek wrote: Thanks for the tip! Looks like I can change my date_archived field to timestamp(8), since all I care about for this is the date information (actual time is useless to me). My sql query all of a sudden got a lot simpler. Thanks again for the help!

Re: INSERT INTO ..... SELECT

2002-05-01 Thread Dave
This was resolved by adding an auto-increment column. MySQL does not seem capable of coping with the situation below. - Original Message - From: Dave [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, April 30, 2002 5:36 PM Subject: INSERT INTO . SELECT I am having problems

Re: INSERT DELAYED...SELECT... doesn't delay?

2002-04-30 Thread Rob Shearer
What analysis are you performing which causes you to conclude that nothing is being delayed? I'd probably check this by creating an insert...select which takes at least a few seconds to execute, and then have my test application log the time, make the call to MySQL, and log the time again. I

Re: Insert from select

2002-03-16 Thread Kittiphum Worachat
- Original Message - From: David McInnis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, March 16, 2002 3:26 PM Subject: Insert from select I think that I saw a similar query last week some time but I cannot remember the sql syntax. Is it possible to insert from a select.

Re: Insert from select

2002-03-16 Thread Georg Richter
On Saturday, 16. March 2002 09:26, David McInnis wrote: I think that I saw a similar query last week some time but I cannot remember the sql syntax. Is it possible to insert from a select. See http://www.mysql.com/doc/I/N/INSERT_SELECT.html Regards Georg

Re: insert and select

2002-03-15 Thread c.smart
Hi No you can't. if you are using and AUTO_INCREMENT field as a key you could follow the INSERT with a select statement like: SELECT * FROM tablename WHERE keyfield = LAST_INSERT_ID() See the manual: LAST_INSERT_ID()

RE: INSERT with SELECT on same table

2001-11-15 Thread Votteler Marc
-Ursprüngliche Nachricht- Von: Rick Emery [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 14. November 2001 19:46 An: Votteler Marc; [EMAIL PROTECTED] Betreff: RE: INSERT with SELECT on same table If one of the table's fields is defined as UNIQUE or PRIMARY KEY, it will allow the insertion

RE: INSERT with SELECT on same table

2001-11-15 Thread Jon Gardiner
, November 15, 2001 3:30 AM To: Rick Emery; [EMAIL PROTECTED] Subject: RE: INSERT with SELECT on same table Thanks for the response, you are right I would get an Exception describing that the record already exists, but because I do not know which DBMS is being used (one of Oracle, MS SQL

RE: INSERT with SELECT on same table

2001-11-15 Thread Carsten H. Pedersen
insert-select on the same table is not allowed in MySQL. If I remember right it isn't allowed in ANSI SQL either, supposedly because it could lead to infinite loops if implemented poorly. Jon Gardiner. Core SQL support does not require the DBMS to support it; enhanced SQL support allows

RE: INSERT with SELECT on same table

2001-11-14 Thread Rick Emery
If one of the table's fields is defined as UNIQUE or PRIMARY KEY, it will allow the insertion only once with that key. When a second attempt is made to insert the record with the same key, the insertion will be ignored and you may ignore the error code that results. Would that work for you?

Re: INSERT INTO SELECT ??

2001-10-03 Thread Paul DuBois
At 12:53 PM +0800 10/3/01, chong wee siong wrote: Hi DBAs: I want to copy TableA in DatabaseA to TableB in DatabaseB with changes in the attributes of the tables, what options do I have? I tried these: a) insert into TableB (id) select (id) from DatabaseA.TableA; this works b) insert into