Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2005
    Posts
    85

    Unanswered: MySQL insert query

    Hi,

    I need to insert the value 1, 2, 3, 4 to the columns col1, col2, col3, col4 in a table only if the values 3, 4 does not exists in col3, col4 in the table

    Something like :

    insert into table values(1, 2, 3, 4) where (3, 4) not in select col3, col3 from table

    Kindly post the query

    Thanks,
    MiraJ

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    declare a unique key on (col3,col4), and let the database do the check for you
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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