SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot ozonew4m's Avatar
    Join Date
    Apr 2006
    Location
    at my desk
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multiple on duplicate update

    hello people

    first of all let me explain what im trying to do... every time somebody hits a page on my site refered from google i extract the keywords and i want to add them to a database with the url

    so if i have a table called urls with the following cells

    url_id
    url_url
    url_keyword
    url_hitcount

    what i want is if the url and keyword combination already exists update hitcount+1 if not insert the new url and keyword into the table.

    is it possible to do this with mysqls "on duplicate update" feature or do i need to use multiple queries.

    and

    is it possible to have two unique cells joined so its only unique if both cells dont match?

    hope you understand this.. its a bit hard to explain

    looking forward to your possible solutions

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by ozonew4m View Post
    is it possible to do this with mysqls "on duplicate update" feature
    absolutely, it's a classic example

    Quote Originally Posted by ozonew4m View Post
    is it possible to have two unique cells joined so its only unique if both cells dont match?
    absolutely, declare a UNIQUE index on both columns, i.e. a multi-column index
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •