Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2005
    Posts
    44

    Unanswered: change SELECT query to DELETE query (was "help with a query")

    How can i changed this to a delete query:

    SELECT tw.staff_id, tw.training_id
    FROM tbl_staff_training_wish AS tw, tbl_staff_training AS st
    WHERE (((tw.staff_id)=[st].[staff_id]) AND ((tw.training_id)=[st].[training_id]));

    when i replace the word select with delete it tells me to specify the table..... i am confused!
    Last edited by netherton; 03-04-06 at 12:28.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    DELETE * FROM tw
    WHERE (((tw.staff_id)=[st].[staff_id]) AND ((tw.training_id)=[st].[training_id]));

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    izy, huh?

    your WHERE references two tables, but your DELETE mentions only one

    try this --

    DELETE tw.*
    FROM tbl_staff_training_wish AS tw, tbl_staff_training AS st
    WHERE (((tw.staff_id)=[st].[staff_id]) AND ((tw.training_id)=[st].[training_id]));


    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Apr 2005
    Posts
    44
    thanks guys that really helps but now it says it cant not delete from specified table??? wats that supposed to mean

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try it like this --

    DELETE tbl_staff_training_wish.*
    FROM tbl_staff_training_wish
    , tbl_staff_training
    WHERE tbl_staff_training_wish.staff_id = tbl_staff_training.staff_id
    AND tbl_staff_training_wish.training_id = tbl_staff_training.training_id
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hi Rudy,

    was netherton's WHERE copy/pasted, but yeah: strictly crap
    ...i'm still working on my reading skills.

    izy
    currently using SS 2008R2

Posting Permissions

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