RE: Check for data before inserting

2003-10-17 Thread Mike Knox
Message- From: Brent Baisley [mailto:[EMAIL PROTECTED] Sent: 16 October 2003 19:29 To: Mike Tuller Cc: MySql List Subject: Re: Check for data before inserting It sound like you want to use REPLACE instead of the SELECT and INSERT/UPDATE combo. Replace will insert if the record doesn't exist

Re: Check for data before inserting

2003-10-17 Thread Director General: NEFACOMP
or primary key) Thanks Emery - Original Message - From: Mike Knox [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 17, 2003 09:44 Subject: RE: Check for data before inserting Traditionally, I'd take the following approach 1) Update - assume it's there 2) If update fails (0

Re: Check for data before inserting

2003-10-17 Thread gerald_clark
Mike Knox wrote: Traditionally, I'd take the following approach 1) Update - assume it's there 2) If update fails (0 rows) do an insert Thats assuming that the update case is more prevalent. If the row is unlikely to be there - insert and do the update if you get a duplicate key. You have

RE: Check for data before inserting

2003-10-17 Thread Simon Green
Why would the REPLACE statement not work? Simon (ps mite have missed some thing if so sorry) -Original Message- From: gerald_clark [mailto:[EMAIL PROTECTED] Sent: 17 October 2003 14:08 To: Mike Knox Cc: '[EMAIL PROTECTED]' Subject: Re: Check for data before inserting Mike Knox wrote

Re: Check for data before inserting

2003-10-17 Thread gerald_clark
wrote: Why would the REPLACE statement not work? Simon (ps mite have missed some thing if so sorry) -Original Message- From: gerald_clark [mailto:[EMAIL PROTECTED] Sent: 17 October 2003 14:08 To: Mike Knox Cc: '[EMAIL PROTECTED]' Subject: Re: Check for data before inserting Mike Knox

Re: Check for data before inserting

2003-10-17 Thread Director General: NEFACOMP
: Friday, October 17, 2003 15:44 Subject: Re: Check for data before inserting I didn't say it wouldn't. I was pointing out the danger of the method listed. Also, a danger with replace is that multiple records might be deleted for one insert if there are multiple unique keys in the table

Re: Check for data before inserting

2003-10-17 Thread Gabriel Ricard
) Thanks Emery - Original Message - From: Mike Knox [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 17, 2003 09:44 Subject: RE: Check for data before inserting Traditionally, I'd take the following approach 1) Update - assume it's there 2) If update fails (0 rows) do an insert

Check for data before inserting

2003-10-16 Thread Mike Tuller
I have a shell script that I have data entered into a database, and instead of just entering in the data blindly, I want it to check to see if the item it is entering exists already, and if it does, update the information rather than inserting it. So I want to run a select statement, and if

Re: Check for data before inserting

2003-10-16 Thread Brent Baisley
It sound like you want to use REPLACE instead of the SELECT and INSERT/UPDATE combo. Replace will insert if the record doesn't exist and update if it does. On Thursday, October 16, 2003, at 01:27 PM, Mike Tuller wrote: I have a shell script that I have data entered into a database, and

Re: Check for data before inserting

2003-10-16 Thread Mike Tuller
, if there is no match, then the data is inserted into a new row. Mike From: Brent Baisley [EMAIL PROTECTED] Date: Thu, 16 Oct 2003 14:29:21 -0400 To: Mike Tuller [EMAIL PROTECTED] Cc: MySql List [EMAIL PROTECTED] Subject: Re: Check for data before inserting It sound like you want to use REPLACE

Re: Check for data before inserting

2003-10-16 Thread Ray
actually it will act like insert in eather case. if its there, delete it first, if not just insert. http://www.mysql.com/doc/en/REPLACE.html as far as using shell to do the insert/update, you could look at command line php, that way you get the logic and you don't have to learn a new

Re: Check for data before inserting

2003-10-16 Thread gerald_clark
You are confusing the string function with the sql function. Mike Tuller wrote: Unless I am mistaken on REPLACE's use, I don't think that will work. The example I have in the O'Reilly MySql book that I have shows this. REPLACE(string, old, new) Returns a string that has all occurances of the