Re: Sql gurus

2002-02-05 Thread DL Neil

Hi Peter,

 I am working on a search logging script to count the most popular word or
 phrases searched for.
 
 Table
 
 I could add a line for each search, and aggregate the results for reports,
 but I was wondering about the following which would keep table sizes down.
 
 | search word  | count  |
 =
 | Nuts |125 |
 | Bolts|119 |
 | Screws   |110 |
 | Washers  | 98 |
 
 If the word is already in the table increment the counter, if not add the
 word and set counter to 1
 
 query 1 = update counter where word = search word
 
 if no records updated
 query 2 = insert word and set counter to 1
 
 Is there a single query that will do this or does it have to be 2?


Two - sorry!
=dn



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Sql gurus

2002-02-05 Thread Peter Lovatt

Oh well worth a try

Thanks

Peter

---
Excellence in internet and open source software
---
Sunmaia
www.sunmaia.net
[EMAIL PROTECTED]
tel. 0121-242-1473
--- 

 -Original Message-
 From: DL Neil [mailto:[EMAIL PROTECTED]]
 Sent: 05 February 2002 17:58
 To: Peter Lovatt; [EMAIL PROTECTED]
 Subject: Re: Sql gurus
 
 
 Hi Peter,
 
  I am working on a search logging script to count the most 
 popular word or
  phrases searched for.
  
  Table
  
  I could add a line for each search, and aggregate the results 
 for reports,
  but I was wondering about the following which would keep table 
 sizes down.
  
  | search word  | count  |
  =
  | Nuts |125 |
  | Bolts|119 |
  | Screws   |110 |
  | Washers  | 98 |
  
  If the word is already in the table increment the counter, if 
 not add the
  word and set counter to 1
  
  query 1 = update counter where word = search word
  
  if no records updated
  query 2 = insert word and set counter to 1
  
  Is there a single query that will do this or does it have to be 2?
 
 
 Two - sorry!
 =dn
 
 
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail 
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php