Help with join, delete

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    #1

    Help with join, delete

    I am not a sql person and could use some help with a delete...here is
    what I want:

    I have the following tables/fields (only including necessary fields)

    answers
    result_id

    results
    result_id
    points

    I want to delete the records for result_id from both tables when
    points in the results table <50

    Thanks in advance for any assistance.

    Mike
  • Aggro

    #2
    Re: Help with join, delete

    Mike wrote:
    [color=blue]
    > I have the following tables/fields (only including necessary fields)
    >
    > answers
    > result_id
    >
    > results
    > result_id
    > points
    >
    > I want to delete the records for result_id from both tables when
    > points in the results table <50[/color]

    This might help:
    http://dev.mysql.com/doc/mysql/en/DELETE.html

    But please note the part saying:
    "From MySQL 4.0, you can specify multiple tables in the DELETE statement
    to delete rows from one or more tables depending on a particular
    condition in multiple tables. However, you cannot use ORDER BY or LIMIT
    in a multiple-table DELETE.

    The first multiple-table DELETE syntax is supported starting from MySQL
    4.0.0. The second is supported starting from MySQL 4.0.2. The
    table_reference s part lists the tables involved in the join. Its syntax
    is described in section 14.1.7.1 JOIN Syntax. "

    Comment

    • Mike

      #3
      Re: Help with join, delete

      It help a little...But I still need some guidance.

      This selects what I want:
      SELECT * FROM answers, results WHERE
      answers.result_ id=results.resu lt_id AND results.score <50

      so I would think this would delete it:
      DELETE FROM answers, results WHERE answers.result_ id=results.resu lt_id
      AND results.score <50

      but it doesn't, can anyone shed some light on it?

      Thanks Mike

      Aggro <spammerdream@y ahoo.com> wrote in message news:<3aQOc.232 $Zb7.128@read3. inet.fi>...[color=blue]
      > Mike wrote:
      >[color=green]
      > > I have the following tables/fields (only including necessary fields)
      > >
      > > answers
      > > result_id
      > >
      > > results
      > > result_id
      > > points
      > >
      > > I want to delete the records for result_id from both tables when
      > > points in the results table <50[/color]
      >
      > This might help:
      > http://dev.mysql.com/doc/mysql/en/DELETE.html
      >
      > But please note the part saying:
      > "From MySQL 4.0, you can specify multiple tables in the DELETE statement
      > to delete rows from one or more tables depending on a particular
      > condition in multiple tables. However, you cannot use ORDER BY or LIMIT
      > in a multiple-table DELETE.
      >
      > The first multiple-table DELETE syntax is supported starting from MySQL
      > 4.0.0. The second is supported starting from MySQL 4.0.2. The
      > table_reference s part lists the tables involved in the join. Its syntax
      > is described in section 14.1.7.1 JOIN Syntax. "[/color]

      Comment

      • Aggro

        #4
        Re: Help with join, delete

        Mike wrote:
        [color=blue]
        > so I would think this would delete it:
        > DELETE FROM answers, results WHERE answers.result_ id=results.resu lt_id
        > AND results.score <50
        >
        > but it doesn't, can anyone shed some light on it?[/color]

        What version of MySQL server you are using?

        Comment

        • Mike

          #5
          Re: Help with join, delete

          It help a little...But I still need some guidance.

          This selects what I want:
          SELECT * FROM answers, results WHERE
          answers.result_ id=results.resu lt_id AND results.score <50

          so I would think this would delete it:
          DELETE FROM answers, results WHERE answers.result_ id=results.resu lt_id
          AND results.score <50

          but it doesn't, can anyone shed some light on it?

          Thanks Mike

          Aggro <spammerdream@y ahoo.com> wrote in message news:<3aQOc.232 $Zb7.128@read3. inet.fi>...[color=blue]
          > Mike wrote:
          >[color=green]
          > > I have the following tables/fields (only including necessary fields)
          > >
          > > answers
          > > result_id
          > >
          > > results
          > > result_id
          > > points
          > >
          > > I want to delete the records for result_id from both tables when
          > > points in the results table <50[/color]
          >
          > This might help:
          > http://dev.mysql.com/doc/mysql/en/DELETE.html
          >
          > But please note the part saying:
          > "From MySQL 4.0, you can specify multiple tables in the DELETE statement
          > to delete rows from one or more tables depending on a particular
          > condition in multiple tables. However, you cannot use ORDER BY or LIMIT
          > in a multiple-table DELETE.
          >
          > The first multiple-table DELETE syntax is supported starting from MySQL
          > 4.0.0. The second is supported starting from MySQL 4.0.2. The
          > table_reference s part lists the tables involved in the join. Its syntax
          > is described in section 14.1.7.1 JOIN Syntax. "[/color]

          Comment

          • Aggro

            #6
            Re: Help with join, delete

            Mike wrote:
            [color=blue]
            > so I would think this would delete it:
            > DELETE FROM answers, results WHERE answers.result_ id=results.resu lt_id
            > AND results.score <50
            >
            > but it doesn't, can anyone shed some light on it?[/color]

            What version of MySQL server you are using?

            Comment

            Working...