# SQL DELETE with subquery

**URL:** <https://forum.codewithmosh.com/t/sql-delete-with-subquery/25707>\
**Category:** Uncategorized\
**Created:** [March 18, 2024, 8:47pm UTC](https://forum.codewithmosh.com/t/sql-delete-with-subquery/25707 "2024-03-18T20:47:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuacos2777](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@joshuacos2777](https://forum.codewithmosh.com/u/joshuacos2777)\
**Post date:** [March 18, 2024, 8:47pm UTC](https://forum.codewithmosh.com/t/sql-delete-with-subquery/25707/1 "2024-03-18T20:47:29Z")

</div>

Hi,  
I try to delete a record from a table by using a subquery but getting an error message.  
here is the query below:  
DELETE FROM invoices  
WHERE client\_id =(  
SELECT client\_id  
FROM clients  
WHERE name=‘Yadel’  
);

the error message is :operand should contain 1 column(s)

---

<div class="post-metadata">

**Author:** ![thusith](https://avatars.discourse-cdn.com/v4/letter/t/f4b2a3/32.png) [@thusith](https://forum.codewithmosh.com/u/thusith)\
**Post date:** [April 2, 2024, 9:04pm UTC](https://forum.codewithmosh.com/t/sql-delete-with-subquery/25707/2 "2024-04-02T21:04:45Z")

</div>

Your query is incorrect it should read as below you need to use IN operator

DELETE FROM invoices  
WHERE client\_id IN (  
SELECT client\_id  
FROM clients  
WHERE name=‘Yadel’  
);
