Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    Pinoy in NJ
    Posts
    104

    Question Unanswered: Deleting records.

    Anyone have ideas on how to delete records (see code below). I keep on getting the error message:

    "The column prefix 'employee' does not match with a table name or alias name used in the query."

    All I want to do is to remove the records in the EMPRATES table where the EMPLOYEEID and RATE are the same in the EMPLOYEE table. What am I missing?



    Code:
    delete emprates 
    where 
    emprates.employeeid = employee.employeeid 
    and emprates.rate=employee.rate

  2. #2
    Join Date
    Sep 2003
    Posts
    522
    delete emprates from emprates
    inner join employee on
    emprates.employeeid = employee.employeeid
    and emprates.rate=employee.rate

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    delete from emprates
    where exists
    ( select 1 from employee
    where employeeid = emprates.employeeid
    and rate = emprates.rate )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    May 2003
    Location
    Pinoy in NJ
    Posts
    104

    Thumbs up

    I tried both syntax and they both perfomed what I needed. The first one had a lower execution cost though.

    Thanks again.

Posting Permissions

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