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: 
Try this: 

```
DELETE FROM posts 
WHERE id IN (SELECT id 
             FROM (SELECT post_title, MAX(id) id 
                   FROM posts 
                   WHERE post_title IN ('abc', 'xyz') 
                   GROUP BY post_title 
                  ) A 
            )

```

**OR**

```
DELETE FROM posts 
WHERE id IN (SELECT id 
             FROM (SELECT post_title, id 
                   FROM posts 
                   WHERE post_title IN ('abc', 'xyz') 
                   ORDER BY post_title, id DESC
                 ) A 
            GROUP BY post_title)

```
As a solution to your problem please try executing following sql query

```
delete FROM `posts` WHERE  id in 
(select p.id from 
                 (select id from posts where title in('abc','xyz') p)

```