SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql constraints

    Hii i am building a financial database. And I have data for each stock for all the days. I want to avoid multiple entry of a stock for the same timestamp in the database. For eg I dont want to have the data for google on 30 jun 2010 twice. How can i do this

  2. #2
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please reply asap. Thanks in advance

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by deepak777 View Post
    Please reply asap. Thanks in advance
    as the saying goes...
    failure to plan adequately on your part does not constitute an emergency on our part
    to avoid duplicate entries, declare a UNIQUE index on the key column(s) for those entries

    e.g.

    ALTER TABLE stocks ADD UNIQUE stock_day_ix ( stock_code, value_date )
    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
  •