Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:11:31+00:00 2026-06-12T17:11:31+00:00

This query returns exactly the office tuples I need to delete. SELECT id, reference

  • 0

This query returns exactly the office tuples I need to delete.

    SELECT id, reference FROM office o 
WHERE o.id NOT IN 
    (SELECT c.office_id FROM Contract c  WHERE office_id IS NOT NULL)
AND o.reference IN 
    (SELECT o.reference FROM Contract c JOIN office o ON c.office_id = o.id  WHERE office_id IS NOT NULL);

But when I write the query

    DELETE FROM office 
WHERE id NOT IN 
    (SELECT c.office_id FROM Contract c  WHERE office_id IS NOT NULL)
AND reference IN 
    (SELECT o.reference FROM Contract c JOIN office o ON c.office_id = o.id  WHERE office_id IS NOT NULL);

I have the following error : #1093 - You can't specify target table 'office' for update in FROM clause

But I really don’t see how to solve this..

Any help would be much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:11:32+00:00Added an answer on June 12, 2026 at 5:11 pm

    try

     DELETE FROM office 
     WHERE id NOT IN 
    (SELECT c.office_id FROM Contract c
     WHERE office_id IS NOT NULL)
     AND reference IN 
    (select * from (SELECT o.reference FROM Contract c 
     JOIN office o ON c.office_id = o.id 
     WHERE office_id   IS NOT NULL) x);
    

    since you can’t delete from a table where you are selecting from. But using

    select * from (select col from your_table) x
    

    should do the trick

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain why this query returns an empty result. SELECT * FROM (`bookmarks`)
I've got this query which is quite specific and returns exactly what I need.
I currently have this query: SELECT s_id FROM orderline,order_t WHERE orderline.o_id=order_t.o_id AND c_name='John Smith';
I have the following query that returns exactly what I need, var dataRows =
While debugging into some Oracle code, I came across this query: SELECT TPM_TASK.TASKID FROM
I'm gettintg crazy with the result of this query This query returns 29.970 rows
I have this query that returns the results by ordering it by focus.name ASC.
I have this query which returns a result set with Date(column) as nvarchar datatype.
I have this query: select qa_returns_items.item_code, (CASE status_code WHEN 11 THEN (qa_returns_items.item_quantity - qa_returns_residues.item_quantity)
Mysql query returns result like this collector amount name 1 0.00 gihan 1 2000.00

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.