Question: First query 

```
    select id from posts where post_title='abc' || post_title='xyz' order by id desc limit 1;

```

Let's say the returned values are 730 and 735.

Next query

```
    delete from posts where id in(730,735);

```

I want both of these queries to be combined into one statement. How can it be done. Please help

I have tried this one below. it doesn't work. 

```
delete from posts where id in
        (
            select id from posts where post_title='abc' order by id desc limit 1,
                            select id from posts where post_title='xyz' order by id desc limit 1
                        );

```

Answer: 
In my opinion, We must use **IF-EXISTS** clause when executing delete-and-select in one query, because if select returns null, it will throw an exception so try this: 

```
IF EXISTS (SELECT id FROM [Posts] WHERE post_title IN ('abc', 'xyz'))
BEGIN 
     DELETE FROM posts 
     WHERE id IN (SELECT id 
                  FROM [Posts]
                  WHERE post_title IN ('abc', 'xyz') 
                  ORDER BY post_title, id DESC
                 ) 
END

```
Try this 

```
DELETE FROM [posts]
WHERE id = ANY( SELECT id FROM [posts] WHERE post_title IN('abc','xyz') );

```