SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query to insert data

    in table1 i hvae columns E1,E2, E3,E4,E5,P1,P2,P3,P4,P5 if the values in e1,e2,e3,e4,e5,e6 are not null or blank i want to insert the data in table2 having fields EMAIl & Pass id it does not exists , else update

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    which database system are you using? mysql?

    also, where did e6 come from? it is not a column in table1

    and which values do you want to insert into table2? from which columns in table1?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    table1 has 10 columns E1--- E5 & P1-- P5 with data if any column from table1 ie E1-- E5 then skip the blank column rest data to be inserted in table2 having columns EMAIL & PASS EMAIL coulmn will contain data from column E1--E5 & pass will contain data P1---P5 if the E1 data already exists tehn update ELSE iNSERT i hope its clear x,z,c was the data from columns E

    there is no E6
    using sQl server

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    please explain "if the data already exists then update"

    if which data exists where? then update what?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if the same data from e1... to e5 exists the update table2, else insert if new data

    it can be either update or delete the existing

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by svibuk View Post
    if the same data from e1... to e5 exists the update table2, else insert if new data
    update which columns in table 2 with what???

    you do not seem to understand that we find your specifications to be very vague

    perhaps you could give some sample data for each table and show exactly what needs to be done that way
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)


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
  •