MySQL DB Question

Discussion in 'Programming' started by amelen, Jan 5, 2010.

  1. #1
    Quick mysql db question for the experts out there.

    I have two mysql tabes:

    Table1
    ID
    username

    Table2
    ID
    username
    email


    How can I find all the records that have a certain "email" address in table 2 and then delete those records from both table 1 and table 2?
     
    amelen, Jan 5, 2010 IP
  2. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I will write the sql, but you will have to debug and get it working.

    First call the following SQL
    ====================
    delete from table1 where id in (select id from table2 where email = 'name@yordomain.com')

    Then call this
    ==========
    delete from table2 where email = 'name@yordomain.com
     
    NeoCambell, Jan 6, 2010 IP
  3. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    do you know
    if you renamed it like that
    Table1
    Table1_ID
    Table1_username

    Table2
    Table2_ID
    Table2_username
    Table2_email

    beause of if you want to make it in one query
     
    astkboy2008, Jan 6, 2010 IP
  4. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    do you know
    if you renamed it like that
    Table1
    Table1_ID
    Table1_username

    Table2
    Table2_ID
    Table2_username
    Table2_email

    beause of if you want to make it in one query
     
    astkboy2008, Jan 6, 2010 IP
  5. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #5
    Thanks!!!!
     
    amelen, Jan 6, 2010 IP