# Subquery help

**URL:** <https://forum.kirupa.com/t/subquery-help/272221>\
**Category:** programming\
**Created:** [October 3, 2008, 2:16am UTC](https://forum.kirupa.com/t/subquery-help/272221 "2008-10-03T02:16:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Icy\_Penguin](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@Icy\_Penguin](https://forum.kirupa.com/u/Icy_Penguin)\
**Post date:** [October 3, 2008, 2:16am UTC](https://forum.kirupa.com/t/subquery-help/272221/1 "2008-10-03T02:16:44Z")

</div>

So I’ve been looking around and keep on getting errors when I try this, so…

I need to count all the rows from a table whose book ID is the same book ID as a bunch of rows whose user ID is a known number, say 1.

So, something like this:

```auto
 SELECT id FROM posts WHERE book = (SELECT book FROM posts WHERE user='$user_id') 

```

The purpose of this query is to count all the books posted by other users (that are the same book).
