update, insert ... gee.. a puzzle

2016-03-19 Thread lejeczek
.. that you experts I hope can crack like a digestive biscuit... how does one update, or merge or whatever is right technical term for it - a my.table from my.another table (both are schematically identical, no foreign keys, one primary key) but.. does it a way so when there is a duplicate on

Re: update, insert ... gee.. a puzzle

2016-03-18 Thread Hal.sz S.ndor
so when there is a duplicate only NULLs in my.table get updated/replaced with proper values from my.another table? many thanks, specially for actual syntax hints. Nothing here is easy My best is INSERT ... SELECT ... ON DUPLICATE KEY UPDATE ...; INSERT INTO my.table SELECT * FROM my."an

Re: How to get auto Increment ID of INSERT?

2015-10-08 Thread Carsten Pedersen
RT_ID(). Best, / Carsten On 08-10-2015 15:48, Richard Reina wrote: If I insert a record into a table with an auto increment ID how can I get that records ID value? I have read about SELECT LAST_INSERT_ID() statement, however, do not two statements introduce the risk that another insert may occ

How to get auto Increment ID of INSERT?

2015-10-08 Thread Richard Reina
If I insert a record into a table with an auto increment ID how can I get that records ID value? I have read about SELECT LAST_INSERT_ID() statement, however, do not two statements introduce the risk that another insert may occur in the interum? Is there a full proof way of getting the ID of the

Re: MySQL 5.5 Slow performance to insert

2015-07-27 Thread shawn l.green
8 row lock(s) MySQL thread id 15361, OS thread handle 0x7fea5e5c2700, query id 2690080 10.180.17.252 root Copying to tmp table insert into CONFERENCIA_ENCALHE (data, preco_capa_informado, qtde, qtde_informada, chamada_encalhe_cota_id, controle_conferencia_encalhe_cota_id, movimento_estoq

Re: MySQL 5.5 Slow performance to insert

2015-07-27 Thread Johan De Meersman
- Original Message - > From: "Camilo Vieira" > Subject: Re: MySQL 5.5 Slow performance to insert > $ ./mysqltuner.pl --user root --pass abril@123 Thank you for that password :-) I don't particularly like MySQLtuner myself, it makes assumptions about your workl

Re: MySQL 5.5 Slow performance to insert

2015-07-27 Thread Camilo Vieira
LATEST FOREIGN KEY ERROR >> >> 150722 18:23:08 Transaction: >> TRANSACTION 31AC5E3, ACTIVE 8 sec inserting >> mysql tables in use 3, locked 3 >> 826 lock struct(s), heap size 96696, 31241 row lock(s), undo log entries >> 9932 >

Re: MySQL 5.5 Slow performance to insert

2015-07-25 Thread yoku ts.
Hi, Your INSEERquery status is "Copying to tmp table", this means fetching rows which has to be inserted is slow. You should tune SELECT statement in your insert query. Adding indexes and/or simplifying query and/or .. so on. ``` ---TRANSACTION 31D6D74, ACTIVE 27107 sec mysql table

MySQL 5.5 Slow performance to insert

2015-07-24 Thread Camilo Vieira
32 MySQL thread id 932, OS thread handle 0x7feaf0042700, query id 42396 10.180.17.252 root insert into movimento_estoque_cota ( ID,APROVADO_AUTOMATICAMENTE,DATA_APROVACAO,STATUS,DATA,DATA_CRIACAO,TIPO_MOVIMENTO_ID,USUARIO_ID, QTDE,PRODUTO_EDICAO_ID,COTA_ID,ESTOQUE_PROD_COTA_ID,ORIGEM,APRO

Problem with INSERT INTO and UPDATE queries

2014-06-25 Thread Antonio Fernández Pérez
​Hi list, I have some problems with INSERT INTO and UPDATE queries on a big table. Let me put the code and explain it ... I have copied the create code of the table. This table has more than 1500 rows. ​Create Table: CREATE TABLE `radacct` ( `RadAcctId` bigint(21) NOT NULL AUTO_INCREMENT

Re: Really slow batch insert??

2013-12-30 Thread hsv
where we want to do bulk inserts (3000 inserts) using: INSERT INTO (id, productId, category) VALUES (‘x1’, ‘y1’, ‘z1’), (‘x2’, ‘y2’, ‘z3’) ….. ON DUPLICATE KEY productId = VALUES(productId), category = VALUES(category) So, when we try to insert 3000 rows using this syntax with a single statement,

Re: Really slow batch insert??

2013-12-30 Thread Cabbar Duzayak
and we have a unique index on > (category, productId). And, there is a case where we want to do bulk > inserts (3000 inserts) using: > > > INSERT INTO (id, productId, category) VALUES (‘x1’, ‘y1’, ‘z1’), (‘x2’, > ‘y2’, ‘z3’) ….. ON DUPLICATE KEY productId = VALUES(productId), cat

Really slow batch insert??

2013-12-30 Thread Cabbar Duzayak
Hi, We have a basic table, which is something like : (id varchar50, productId varchar50, category varchar50) In this table, ID is the primary key and we have a unique index on (category, productId). And, there is a case where we want to do bulk inserts (3000 inserts) using: INSERT INTO (id

Re: MUltiple value in single insert is not working in mysql procedure

2012-12-05 Thread hsv
2012/12/03 19:10 +0530, amit Problem mysql> call mobile_series1('(99889988),(12334565)'); You are expecting MySQL to turn one string operand into twain number operands. That does not happen, unless you use PREPARE, which, I suspect, is not part of your homework. -- MySQL Ge

Re: MUltiple value in single insert is not working in mysql procedure

2012-12-03 Thread Peter Brawley
On 2012-12-03 7:40 AM, amit wrote: Hi Team, I am not able to use multi value insert via argument in mysql stored procedure, Please help where am I wrong. Thanks in Advance ! mysql> insert into input_data1 values(),(),(),(); Query OK, 4 rows affected (0.00 sec) *Prob

Re: Possible to copy the key field to another on INSERT?

2012-10-17 Thread W. D.
At 02:44 10/17/2012, Claudio Nanni wrote: >Take a look at TRIGGERS > >C. Thanks Claudio. I wrote a trigger that MySQL accepted. However, when I tried to insert a new record: "Can't update table 'tbl' in stored function/trigger because it is already us

Re: Possible to copy the key field to another on INSERT?

2012-10-17 Thread W. D.
At 02:44 10/17/2012, Claudio Nanni, wrote: >Take a look at TRIGGERS > >C. > >PS: I am curious to know why you would do that anyway Will want this 'AssociatedWith' field to be associated with an older records' KeyField so I can search for a group of records by this field. Start Here to Find

Re: Possible to copy the key field to another on INSERT?

2012-10-17 Thread Dehua Yang
e for the > current connection. Only actions taken by the current connection can > change this value. > > http://dev.mysql.com/doc/**refman/5.5/en/information-** > functions.html#function_last-**insert-id<http://dev.mysql.com/doc/refman/5.5/en/information-functions.html#function_last-ins

Re: Possible to copy the key field to another on INSERT?

2012-10-17 Thread Shawn Green
for the current connection. Only actions taken by the current connection can change this value. http://dev.mysql.com/doc/refman/5.5/en/information-functions.html#function_last-insert-id -- Shawn Green MySQL Principal Technical Support Engineer Oracle USA, Inc. - Hardware and Software

Re: Possible to copy the key field to another on INSERT?

2012-10-17 Thread Claudio Nanni
> another field when using the same INSERT that creates the record? > > Or would I have to use an UPDATE query using LAST_INSERT_ID() > immediately after the INSERT statement? > > Thanks for any ideas you have. > > Start Here to Find It Fast!™ -> > http://www.US-Webmast

Re: Possible to copy the key field to another on INSERT?

2012-10-17 Thread Dehua Yang
ossible to copy this auto-generated value into > another field when using the same INSERT that creates the record? > > Or would I have to use an UPDATE query using LAST_INSERT_ID() > immediately after the INSERT statement? > > Thanks for any ideas you have. > > Start He

Possible to copy the key field to another on INSERT?

2012-10-16 Thread W. D.
When creating a record, the first field (KeyField)... KeyFieldBIGINT UNSIGNED NOT NULL AUTO_INCREMENT ...is it possible to copy this auto-generated value into another field when using the same INSERT that creates the record? Or would I have to use an UPDATE query using LAST_INSERT_ID

Re: Which Database when lot of insert / update queries to execute

2012-06-15 Thread hsv
2012/06/15 18:14 +0900, Tsubasa Tanaka try to use `LOAD DATA INFILE' to import from CSV file. http://dev.mysql.com/doc/refman/5.5/en/load-data.html "Try" is the operative word: MySQL s character format is _like_ CSV, but not the same. The treatment of NULL is doubtless the bigg

RE: Which Database when lot of insert / update queries to execute

2012-06-15 Thread Rick James
Database when lot of insert / update queries to execute > > hi, > I am biased on mysql, and hence i am asking this on mysql forum first. > I am designing a solution which will need me to import from CSV, i am > using my JAVA code to parse. CSV file has 500K rows, and i need to do >

Re: Which Database when lot of insert / update queries to execute

2012-06-15 Thread Tsubasa Tanaka
am biased on mysql, and hence i am asking this on mysql forum first. > I am designing a solution which will need me to import from CSV, i am using > my JAVA code to parse. CSV file has 500K rows, and i need to do it thrice > an hour, for 10 hours  a day. > The Queries will mainly be

Which Database when lot of insert / update queries to execute

2012-06-15 Thread abhishek jain
select and insert also at times, The database size will be estimated to be about 5GB. I need to know is this a classic case for a NOSQL database or mysql is a good option. Also , if i need to do 'group by', on a column on a large table what should i keep in mind, is it advisable, Ple

Re: Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-14 Thread Ananda Kumar
I used to have these issues in mysql version 5.0.41. On Mon, May 14, 2012 at 8:13 PM, Johan De Meersman wrote: > - Original Message - > > From: "Ananda Kumar" > > > > If numeric, then why are u using quotes. With quotes, mysql will > > ignore the index and do a full table scan > > Will

Re: Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-14 Thread Johan De Meersman
- Original Message - > From: "Ananda Kumar" > > If numeric, then why are u using quotes. With quotes, mysql will > ignore the index and do a full table scan Will it? Common sense dictates that it would convert to the column's native type before comparing; and a quick explain seems to co

Re: Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-14 Thread Ananda Kumar
stments, but I > think I lost a lot of speed at the insert... > > The database stats are like 95% reading 5% writting...but that 5% is > mostly done in a batch process who happends to be done inside a time > window... > > I know I need to do more profiling, but... at least fo

Re: Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-14 Thread Andrés Tello
es, 1 for each month for 5 years.. I gain a lot of speed with the partitioning and sql adjustments, but I think I lost a lot of speed at the insert... The database stats are like 95% reading 5% writting...but that 5% is mostly done in a batch process who happends to be done inside a time window... I

Re: Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-14 Thread Ananda Kumar
is accountid a number or varchar column On Sat, May 12, 2012 at 7:38 PM, Andrés Tello wrote: > While doning a batch process... > > show full processlist show: > > | 544 | prod | 90.0.0.51:51262 | tmz2012 | Query |6 | > end | update `account` set `balance`= 0.00 + >

RE: Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-14 Thread Steven Staples
> -Original Message- > From: Andrés Tello [mailto:mr.crip...@gmail.com] > Sent: May 12, 2012 10:08 AM > To: mysql > Subject: Mysql is toying me... why sometimes an insert or update can be > slow!? I getting bald cuz this > > While doning a batch process... > &

Mysql is toying me... why sometimes an insert or update can be slow!? I getting bald cuz this

2012-05-12 Thread Andrés Tello
While doning a batch process... show full processlist show: | 544 | prod | 90.0.0.51:51262 | tmz2012 | Query |6 | end | update `account` set `balance`= 0.00 + '-4000' where accountid='2583092' No other process, lo locking no nothing... so you take this same query.

Re: Large insert query gives MySQL server gone away

2011-10-12 Thread Reindl Harald
in both server and client > >> > >> -- > >> *From:* Johnny Withers <mailto:joh...@pixelated.net>> > >> *To:* Neil Tompkins <mailto:neil.tompk...@googlemail.com>> > >> *Cc:* [MySQL] mail

Re: Large insert query gives MySQL server gone away

2011-10-12 Thread Tompkins Neil
> >> *To:* Neil Tompkins > >> *Cc:* [MySQL] > >> *Sent:* Monday, October 10, 2011 4:13 PM > >> *Subject:* Re: Fwd: Large insert query gives MySQL server gone away > >> > >> Max packet size? > >> > >> On Oct 10, 2011 6:12 PM,

Re: Large insert query gives MySQL server gone away

2011-10-12 Thread Reindl Harald
member change >> that value in both server and client >> >> -- >> *From:* Johnny Withers >> *To:* Neil Tompkins >> *Cc:* [MySQL] >> *Sent:* Monday, October 10, 2011 4:13 PM >> *Subject:* Re: Fwd: Large insert query gives

Re: Fwd: Large insert query gives MySQL server gone away

2011-10-12 Thread Tompkins Neil
*From:* Johnny Withers > *To:* Neil Tompkins > *Cc:* [MySQL] > *Sent:* Monday, October 10, 2011 4:13 PM > *Subject:* Re: Fwd: Large insert query gives MySQL server gone away > > Max packet size? > > On Oct 10, 2011 6:12 PM, "Neil Tompkins" > wrote: > &

Re: Fwd: Large insert query gives MySQL server gone away

2011-10-10 Thread Angela liu
Yeah, I think adjusting max packet size may be helpful, remember change that value in both server and client From: Johnny Withers To: Neil Tompkins Cc: [MySQL] Sent: Monday, October 10, 2011 4:13 PM Subject: Re: Fwd: Large insert query gives MySQL server gone

Re: Fwd: Large insert query gives MySQL server gone away

2011-10-10 Thread Johnny Withers
Max packet size? On Oct 10, 2011 6:12 PM, "Neil Tompkins" wrote: > As per the subject we've a large insert query that gives up the error MySQL server has gone away when we try to execute it. Any ideas why ? -- MySQL General Mailing List For list archives: http://lists.

Fwd: Large insert query gives MySQL server gone away

2011-10-10 Thread Neil Tompkins
> As per the subject we've a large insert query that gives up the error MySQL > server has gone away when we try to execute it. Any ideas why ? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Reindl Harald
Am 20.09.2011 01:23, schrieb Dotan Cohen: > On Tue, Sep 20, 2011 at 01:48, Reindl Harald wrote: >> i would use a samll class holding the db-connection with >> insert/update-methods >> pass the whole record-array, lokk what field types are used in the table >> and u

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Tue, Sep 20, 2011 at 01:48, Reindl Harald wrote: > i would use a samll class holding the db-connection with insert/update-methods > pass the whole record-array, lokk what field types are used in the table > and use intval(), doubleval() or mysql_real_escape-String > By the way,

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Tue, Sep 20, 2011 at 01:48, Reindl Harald wrote: > i would use a samll class holding the db-connection with insert/update-methods > pass the whole record-array, lokk what field types are used in the table > and use intval(), doubleval() or mysql_real_escape-String > > so

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
; > > But you're doing exactly that right before the query anyway with: > $M[username]=mysql_real_escape_string($username); > You're just complicating things with the addition of an unneeded array.  It > seems much simpler and less cluttered to just do: >           $someV

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Hank
he query anyway with: $M[username]=mysql_real_escape_string($username); You're just complicating things with the addition of an unneeded array. It seems much simpler and less cluttered to just do: $someVar=mysql_real_escape_string($someVar); before your insert. All you are doing is ch

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Reindl Harald
ySQL >>> $M[username]=mysql_real_escape_string($username); // Everything that >>> goes into $M is escaped >>> $query="INSERT INTO table (username) VALUES ('{$M[username]}')"; >>> >>> >> I'm not sure I'm seeing why, in particu

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
thing that >> goes into $M is escaped >> $query="INSERT INTO table (username) VALUES ('{$M[username]}')"; >> >> > I'm not sure I'm seeing why, in particular, you are using an array here? > I want to be sure that all variables in the que

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Hank
Best of both worlds: > $username=$_POST['username']; > // do some stuff with username here > $M=array(); // Array of things to be inserted into MySQL > $M[username]=mysql_real_escape_string($username); // Everything that > goes into $M is escaped > $query="IN

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Mon, Sep 19, 2011 at 18:11, Reindl Harald wrote: > it is not because it is clear that it is sanitized instead hope and pray > thousands of layers somewhere else did it - for a inline-query the best > solution, if you are using a framework you will never have the "insert into&qu

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Reindl Harald
failure of the query and likely whatever > page, or a soft logical error, which won't. In either case, I have error > trapping to catch both types of errors and alert me to them. I prefer the > errors to be logical ones and not syntax errors. > > >> $sql="INSERT into t

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Hank
7;t. In either case, I have error trapping to catch both types of errors and alert me to them. I prefer the errors to be logical ones and not syntax errors. > $sql="INSERT into table VALUES (" . (int)$id . ",'" . mysql_real_escape_string($val) . "')"; &g

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Mon, Sep 19, 2011 at 07:47, Reindl Harald wrote: > what ugly style - if it is not numeric and you throw it to the database > you are one of the many with a sql-injection because if you are get > ivalid values until there you have done no sanitize before and do not here > > $s

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Dotan Cohen
On Mon, Sep 19, 2011 at 04:00, Hank wrote: > I agree with Brandon's suggestions, I would just add when using numeric > types in PHP statements where you have a variable replacement, for instance: > > $sql="INSERT into table VALUES ('$id','$val')"; &

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Reindl Harald
Am 19.09.2011 03:00, schrieb Hank: > I agree with Brandon's suggestions, I would just add when using numeric > types in PHP statements where you have a variable replacement, for instance: > > $sql="INSERT into table VALUES ('$id','$val')"; &g

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Hank
with Brandon's suggestions, I would just add when using numeric types in PHP statements where you have a variable replacement, for instance: $sql="INSERT into table VALUES ('$id','$val')"; where $id is a numeric variable in PHP and a numeric field in the tabl

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Dotan Cohen
On Sun, Sep 18, 2011 at 17:44, Brandon Phelps wrote: > Personally I don't use any quotes for the numeric types, and single quotes > for everything else.  Ie: > Thanks, Brandon. I understand then that quote type is a matter of taste. I always use double quotes in PHP and I've only recently started

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Brandon Phelps
`varchar_field` = 'Test' WHERE `id` = 3" And some people prefer to put numeric fields in quotes as well, although it is not necessary: UPDATE mytable SET int_field = '5' WHERE id = '3'; On 9/18/11 5:00 AM, Dotan Cohen wrote: I am somewhat confused as to t

Re: stored procedure insert statement

2011-07-09 Thread Igor Shevtsov
Thanks Johnny, In this case I wouldn't be able to insert a completely new row but replace the existent one, so row count would stay the same. This is a storage table with the only unique constraints on: dda_debits_id column. the test data is very small, so I would've noticed any dupl

Re: stored procedure insert statement

2011-07-09 Thread Claudio Nanni
That's what is bad of SP in MySQL, debugging. Just out of the blue, can you try to disable query cache? *SET GLOBAL query_cache_size = 0;* * SET GLOBAL query_cache_type = 0; * it could be a bug Claudio 2011/7/9 Johnny Withers > It seems to me that your insert statement is t

Re: stored procedure insert statement

2011-07-09 Thread Johnny Withers
It seems to me that your insert statement is trying to insert duplicate rows into the storage table. This is why insert ignore and replace work. On Jul 9, 2011 3:49 AM, "Igor Shevtsov" wrote: Hi all, I can't explain strange behaviour of the INSERT statement in the stored procedu

stored procedure insert statement

2011-07-09 Thread Igor Shevtsov
Hi all, I can't explain strange behaviour of the INSERT statement in the stored procedure. The idea is to generate a list based on the output of 3 INNER JOIN of regularly updated tables. Something like : INSERT INTO storage (column list) SELECT column list FROM t1 JOIN t2 ON t1.x=t2.y JOIN

Re: [setting value when INSERT for auto increment]

2011-05-16 Thread Basil Daoust
since your listing the columns, you could just leave off `idlog` from the named columns and thus not also need to include the null in the inserted values. INSERT INTO `friendlyCMS`.`log` (`imepriimek`, `clock`, `action`, `onfile`, `filesize`) VALUES ($_COOKIE['user'], CURRENT_TIMESTA

Re: [setting value when INSERT for auto increment]

2011-05-16 Thread Johan De Meersman
If you're asking what I think you're asking, then yes, both NULL and 0 will trigger an autoincrement field to put in the next value. - Original Message - > From: "Grega Leskovšek" > To: mysql@lists.mysql.com > Sent: Monday, 16 May, 2011 4:49:43 PM > Sub

[setting value when INSERT for auto increment]

2011-05-16 Thread Grega Leskovšek
Should it be null? INSERT INTO `friendlyCMS`.`log` (`idlog`, `imepriimek`, `clock`, `action`, `onfile`, `filesize`) VALUES (NULL, $_COOKIE['user'], CURRENT_TIMESTAMP, 'saved',$filename, filesize($filename)); idlog is primaryk ey auto inrement not null... When insertin the valu

RE: Insert data in one table from Another Problem

2011-02-17 Thread Travis Ard
l Message- From: Adarsh Sharma [mailto:adarsh.sha...@orkash.com] Sent: Wednesday, February 16, 2011 6:33 AM To: mysql@lists.mysql.com Subject: Insert data in one table from Another Problem Dear all, Today I am puzzled around a problem of inserting data into new table in new format. I hav

Insert data in one table from Another Problem

2011-02-16 Thread Adarsh Sharma
Dear all, Today I am puzzled around a problem of inserting data into new table in new format. I have a table named *user_news* as : We have four rows with respect to each record_id. fore.g : I have listed main columns as *record_id field_name field_value* 572SOI

Re: Insert only if the entry doesn't exist

2011-02-15 Thread Joerg Bruehe
Hi! Andre Polykanine wrote: > Hello Rolando, > > So if I do > "INSERT IGNORE INTO `Votes` SET `EntryId`='12345', UserId`='789'"; > it *won't* insert the second row if there's a row with EntryId set to > 12345 and UserId set to 789?

Re: Insert only if the entry doesn't exist

2011-02-14 Thread Andre Polykanine
Hello Rolando, So if I do "INSERT IGNORE INTO `Votes` SET `EntryId`='12345', UserId`='789'"; it *won't* insert the second row if there's a row with EntryId set to 12345 and UserId set to 789? Thanks and sorry!) -- With best regards from Ukraine

RE: Insert only if the entry doesn't exist

2011-02-14 Thread Rolando Edwards
If the table has Primary and/or UNIQUE Keys, then you are fine. You do not need to know what they are. If you want to see them do this: SHOW CREATE TABLE Votes\G INSERT IGNORE INTO does not require ON DUPLICATE KEY options. After all, you said earlier that you want to do nothing if the row

Re: Insert only if the entry doesn't exist

2011-02-14 Thread Andre Polykanine
Hello Rolando, Sorry, but if I do INSERT IGNORE INTO, then I must indicate a key (typically a unique key or a primary key), or is it false? But I don't know that key and no way to get it without more queries... -- With best regards from Ukraine, Andre Skype: Francophile My blog:

RE: Insert only if the entry doesn't exist

2011-02-14 Thread Rolando Edwards
Be Careful. REPLACE INTO mechanically does DELETE and INSERT under mysqld's hood. If you want to do nothing if row exists already then do: INSERT IGNORE instead of REPLACE INTO Rolando A. Edwards MySQL DBA (SCMDBA) 155 Avenue of the Americas, Fifth Floor New York, NY 10013 212-625-5307

Re: Insert only if the entry doesn't exist

2011-02-14 Thread Jo�o C�ndido de Souza Neto
Instead of "insert into" you can use "replace into". -- João Cândido de Souza Neto "Andre Polykanine" escreveu na mensagem news:1621362474.20110214201...@oire.org... Hi all, Thanks for your fast answer to my last question! Here's one more problem I co

Insert only if the entry doesn't exist

2011-02-14 Thread Andre Polykanine
Hi all, Thanks for your fast answer to my last question! Here's one more problem I commonly deal with. There are cases when I need to insert the row only if such a row doesn't exist, otherwise I need either to update the row or to do nothing, just skip the query. The common c

Re: CURRENT insert ID

2011-01-24 Thread Jaime Crespo Rincón
2011/1/21 Jerry Schwartz : >>-Original Message- >>From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br] >>Sent: Friday, January 21, 2011 12:47 PM >>To: mysql@lists.mysql.com >>Subject: Re: CURRENT insert ID >> >>Ok, you must have you

Re: CURRENT insert ID

2011-01-24 Thread Mark Goodge
On 24/01/2011 15:42, Jerry Schwartz wrote: -Original Message- From: Donovan Brooke [mailto:li...@euca.us] Sent: Friday, January 21, 2011 7:28 PM Cc: mysql@lists.mysql.com Subject: Re: CURRENT insert ID Just an idear.. Don't auto_increment the main table.. create a unique Id

RE: CURRENT insert ID

2011-01-24 Thread Jerry Schwartz
>-Original Message- >From: Donovan Brooke [mailto:li...@euca.us] >Sent: Friday, January 21, 2011 7:28 PM >Cc: mysql@lists.mysql.com >Subject: Re: CURRENT insert ID > >Just an idear.. > >Don't auto_increment the main table.. create a unique Id table, >

RE: CURRENT insert ID

2011-01-24 Thread Jerry Schwartz
Cc: 'mysql.' >Subject: Re: CURRENT insert ID > >Seeing from later posts that you're using InnoDB, why don't you simply >wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE, >but I'm not sure I understand the need to mess w/ triggers. >

Re: CURRENT insert ID

2011-01-23 Thread Carsten Pedersen
ehr... Den 23-01-2011 15:36, Carsten Pedersen skrev: Seeing from later posts that you're using InnoDB, why don't you simply wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE, but I'm not sure I understand the need to mess w/ triggers. BEGIN INSERT INTO

Re: CURRENT insert ID

2011-01-23 Thread Carsten Pedersen
Seeing from later posts that you're using InnoDB, why don't you simply wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE, but I'm not sure I understand the need to mess w/ triggers. BEGIN INSERT INTO t(id) NULL UPDATE t SET xxx=last_insert_id() COMMIT B

Re: CURRENT insert ID

2011-01-21 Thread Jesper Wisborg Krogh
20) NOT NULL DEFAULT '' ) ENGINE=InnoDB; INSERT INTO _sequence VALUES ('dupkey', 0); DELIMITER // CREATE TRIGGER befins_dupkey BEFORE INSERT ON dupkey FOR EACH ROW BEGIN DECLARE v_id INT UNSIGNED; UPDATE _sequence SET Value = (LAST_INSERT_ID(Value+1)) where name = 

Re: CURRENT insert ID

2011-01-21 Thread Donovan Brooke
Just an idear.. Don't auto_increment the main table.. create a unique Id table, auto_increment that, and grab that value first for use with both fields in your main table. Donovan -- D Brooke -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:h

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 1:27 PM >To: Jerry Schwartz >Cc: MySql >Subject: Re: CURRENT insert ID > >You don't need to do an update: > >... > >new.xxx = new.id >... >

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br] >Sent: Friday, January 21, 2011 12:47 PM >To: mysql@lists.mysql.com >Subject: Re: CURRENT insert ID > >Ok, you must have your own reasons to do that. > >The fact is: You can

Re: CURRENT insert ID

2011-01-21 Thread Michael Dykman
You don't need to do an update: ... new.xxx = new.id ... On Fri, Jan 21, 2011 at 12:20 PM, Jerry Schwartz wrote: >>-Original Message- >>From: Jerry Schwartz [mailto:je...@gii.co.jp] >>Sent: Friday, January 21, 2011 11:56 AM >>To: 'Michael Dykman'

Re: CURRENT insert ID

2011-01-21 Thread Jo�o C�ndido de Souza Neto
ields, id, s_id. Initially, you insert a record and `id` is now 100 and you update s_id to be 100. But for whatever reason, later down the road you need s_id to be 200. You can just update the s_id field instead of deleting the entire record and inserting an entire new one with X amount of fields. Updati

Re: CURRENT insert ID

2011-01-21 Thread Darryle Steplight
@Joao - I'm currently building a database out right now that has this scenario. One field can be the primary key, that has a purpose for holding the record id, another field can hold the value. Let say there are two fields, id, s_id. Initially, you insert a record and `id` is now 100 an

Re: CURRENT insert ID

2011-01-21 Thread Jo�o C�ndido de Souza Neto
I can´t think about how useful for you would be to have two fields with the same value. -- João Cândido de Souza Neto ""Jerry Schwartz"" escreveu na mensagem news:007501cbb98a$177acba0$467062e0$@co.jp... Here it is in a nutshell: I have a field that needs to be set equal to the auto-inc

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
I made a typo in my previous message. >-Original Message- >From: Jerry Schwartz [mailto:je...@gii.co.jp] >Sent: Friday, January 21, 2011 12:20 PM >To: 'Jerry Schwartz'; 'Michael Dykman'; 'MySql' >Subject: RE: CURRENT insert ID > >

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Jerry Schwartz [mailto:je...@gii.co.jp] >Sent: Friday, January 21, 2011 11:56 AM >To: 'Michael Dykman'; 'MySql' >Subject: RE: CURRENT insert ID > >>-Original Message- >>From: Michael Dykman [mailto:mdyk...

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 11:50 AM >To: MySql >Subject: Re: CURRENT insert ID > >I think an ON INSERT TRIGGER would take care of this; can't think of >any other way. Using last_ins

Re: CURRENT insert ID

2011-01-21 Thread Michael Dykman
I think an ON INSERT TRIGGER would take care of this; can't think of any other way.  Using last_insert_id() in the argument list would likely yield you the previous value (which might not even related to your table. Having siad that..   odd requirement.  - michael dykman ps -- sorr

CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
Here it is in a nutshell: I have a field that needs to be set equal to the auto-increment ID as a record is entered. I don’t know how to do this without a subsequent UPDATE (which I can do with a trigger). Is there any way to avoid the cost of an UPDATE? Here’s a more concrete descrip

Re: INSERT DELAYED and logging

2010-12-23 Thread Alejandro Bednarik
; Yes, I'm to lazy to do it myself, what did you think :-p > > > > > > > > > On Tue, Nov 30, 2010 at 4:01 PM, Wagner Bianchi < > > wagnerbianch...@gmail.com > > > > wrote: > > > > > >> Friends, I did a benchmark regarding to

Re: INSERT DELAYED and logging

2010-12-22 Thread 杨涛涛
gt; Friends, I did a benchmark regarding to this subject. > >> Please, I am considering your comments. > >> => http://wbianchi.wordpress.com/2010/11/30/insert-x-insert-delayed/ > >> > >> Best regards. > >> -- > >> WB > >> > >> > >>

Re: INSERT DELAYED and logging

2010-11-30 Thread Wagner Bianchi
Yes, I'm to lazy to do it myself, what did you think :-p > > > On Tue, Nov 30, 2010 at 4:01 PM, Wagner Bianchi > wrote: > >> Friends, I did a benchmark regarding to this subject. >> Please, I am considering your comments. >> => http://wbianchi.wordpre

Re: INSERT DELAYED and logging

2010-11-30 Thread Johan De Meersman
Friends, I did a benchmark regarding to this subject. > Please, I am considering your comments. > => http://wbianchi.wordpress.com/2010/11/30/insert-x-insert-delayed/ > > Best regards. > -- > WB > > > 2010/11/30 Wagner Bianchi > > Maybe, the table in use mus

Re: INSERT DELAYED and logging

2010-11-30 Thread Wagner Bianchi
Friends, I did a benchmark regarding to this subject. Please, I am considering your comments. => http://wbianchi.wordpress.com/2010/11/30/insert-x-insert-delayed/ Best regards. -- WB 2010/11/30 Wagner Bianchi > Maybe, the table in use must be a table that is inside cache now - SHOW

Re: INSERT DELAYED and logging

2010-11-30 Thread Wagner Bianchi
Maybe, the table in use must be a table that is inside cache now - SHOW OPEN TABLES, controlled by table_cache, I mean. Well, if the amount of data trasactioned is too small as a simple INSERT, you don't have to be worried, I suggest. If you partition the table, we must a benchmark to kno

Re: INSERT DELAYED and logging

2010-11-30 Thread Johan De Meersman
cked against inserts", so the MyISAM insert-while-selecting at the end of a continguous table may well apply. No guarantees, though - I'm not that hot on this depth. On Tue, Nov 30, 2010 at 8:46 AM, WLGades wrote: > What I'm confused by though, is this line. > > "Note

Re: INSERT DELAYED and logging

2010-11-29 Thread WLGades
What I'm confused by though, is this line. "Note that INSERT DELAYED is slower than a normal INSERT if the table is not otherwise in use." What's the definition of "in use"? Does a logging table do that given that it's pretty much append-only/write-only? Wayn

  1   2   3   4   5   6   7   8   9   10   >