Update or insert with a single SQL statement?

2006-03-31 Thread Brian Dunning

I have a really simple two-column database:

domain_name (primary key)
timestamp

I'm trying to keep track of the referrer of every visit to a web  
site, and I'm looking for a single SQL statement (since my ISP limits  
the total number of calls I can make in a day) that will either  
insert a new record if the referring domain is not already in there,  
or simply update the timestamp if the referring domain is already in  
there.


Possible?

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Update or insert with a single SQL statement?

2006-03-31 Thread Greg Donald
On 3/31/06, Brian Dunning [EMAIL PROTECTED] wrote:
 I have a really simple two-column database:

 domain_name (primary key)
 timestamp

 I'm trying to keep track of the referrer of every visit to a web
 site, and I'm looking for a single SQL statement (since my ISP limits
 the total number of calls I can make in a day) that will either
 insert a new record if the referring domain is not already in there,
 or simply update the timestamp if the referring domain is already in
 there.

 Possible?

REPLACE INTO

http://dev.mysql.com/doc/refman/5.0/en/replace.html


--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: Update or insert with a single SQL statement?

2006-03-31 Thread Shaunak Kashyap
Or the more standard INSERT... ON DUPLICATE KEY UPDATE

http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

Shaunak Kashyap
 
Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870
Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the
attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.


 -Original Message-
 From: Greg Donald [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 31, 2006 2:38 PM
 To: mysql@lists.mysql.com
 Subject: Re: Update or insert with a single SQL statement?
 
 On 3/31/06, Brian Dunning [EMAIL PROTECTED] wrote:
  I have a really simple two-column database:
 
  domain_name (primary key)
  timestamp
 
  I'm trying to keep track of the referrer of every visit to a web
  site, and I'm looking for a single SQL statement (since my ISP
limits
  the total number of calls I can make in a day) that will either
  insert a new record if the referring domain is not already in there,
  or simply update the timestamp if the referring domain is already in
  there.
 
  Possible?
 
 REPLACE INTO
 
 http://dev.mysql.com/doc/refman/5.0/en/replace.html
 
 
 --
 Greg Donald
 Zend Certified Engineer
 MySQL Core Certification
 http://destiney.com/
 
 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]