delete data from two tables at the same time...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vyon13
    New Member
    • Feb 2008
    • 8

    delete data from two tables at the same time...

    cn anyone help me.. this is my query in delting data from to two tables at the same time..

    Code:
    $query = DELETE FROM tblpost AND tblreply WHERE post_id = $_GET['id'];
    hope you can help me.. thanks!!!
  • rpnew
    New Member
    • Aug 2007
    • 189

    #2
    Originally posted by vyon13
    cn anyone help me.. this is my query in delting data from to two tables at the same time..

    Code:
    $query = DELETE FROM tblpost AND tblreply WHERE post_id = $_GET['id'];
    hope you can help me.. thanks!!!
    hi,
    You can use something like this........
    [CODE=mysql]
    delete f,s from tblpost f , tblreply s where f.post_id='cond ition' and s.post_id='cond ition';
    [/CODE]

    I'm not sure about the where condition clause.... you can check it on google....

    Regards,
    RP

    Comment

    • ifedi
      New Member
      • Jan 2008
      • 60

      #3
      Originally posted by vyon13
      cn anyone help me.. this is my query in delting data from to two tables at the same time..

      Code:
      $query = DELETE FROM tblpost AND tblreply WHERE post_id = $_GET['id'];
      hope you can help me.. thanks!!!
      Why do you want to squeeze two sql statements into one, anyway?
      You could make sequential delete statements, using a delimiter (usually as semicolon) like so:
      Code:
      $sql="DELETE from tblpost WHERE id= $_GET['id']; DELETE from tblreply WHERE id=$_GET['id']";
      ...
      alternatively:
      Code:
      $sql = "DELETE from tblpost WHERE id = $_GET['id']";
      $sql .= "DELETE from tblreply WHERE id = $_GET['id']";
      Regards,
      Ifedi.

      Comment

      • vyon13
        New Member
        • Feb 2008
        • 8

        #4
        Originally posted by ifedi
        Why do you want to squeeze two sql statements into one, anyway?
        You could make sequential delete statements, using a delimiter (usually as semicolon) like so:
        Code:
        $sql="DELETE from tblpost WHERE id= $_GET['id']; DELETE from tblreply WHERE id=$_GET['id']";
        ...
        alternatively:
        Code:
        $sql = "DELETE from tblpost WHERE id = $_GET['id']";
        $sql .= "DELETE from tblreply WHERE id = $_GET['id']";
        Regards,
        Ifedi.
        thanks all!! GOD Bless..

        Comment

        Working...