I have two tables like this:

```
// Posts
+----+---------+-----------------+----------+
| id |  title  |    content      |  amount  |
+----+---------+-----------------+----------+
| 1  | title1  | content1        | NULL     |
| 2  | title2  | content2        | 1000     |
| 3  | title3  | content3        | 5000     |
| 4  | title4  | content4        | NULL     |
| 5  | title5  | content5        | 2000     |
+----+---------+-----------------+----------+
//                                 ^ NULL means that question is free

// Money_Paid
+----+---------+---------+
| id | user_id | post_id |
+----+---------+---------+
| 1  | 123     | 2       |
| 2  | 345     | 5       |
| 3  | 123     | 5       |
+----+---------+---------+

```

**All I'm trying to do:** Some of my posts aren't free and anybody wants to see them should pay their cost. Now I need a query to check current user paid the cost of that post or not? *(just for non-free post)*

```
SELECT * FROM Posts p WHERE id = :post_id
LEFT JOIN Money_Paid mp ON p.amount IS NOT NULL AND ...

```

---

Here is a few **examples**: *(based on current tables)*

```
$stm->bindValue(":post_id", 2, PDO::PARAM_INT);
$stm->bindValue(":user_id", 123, PDO::PARAM_INT);
//=> TRUE (the user of '123' can see this post because he paid post's cost)

$stm->bindValue(":post_id", 2, PDO::PARAM_INT);
$stm->bindValue(":user_id", 345, PDO::PARAM_INT);
//=> FALSE (the user of '345' cannot see this post because he didn't pay post's cost)

$stm->bindValue(":post_id", 5, PDO::PARAM_INT);
$stm->bindValue(":user_id", 345, PDO::PARAM_INT);
//=> TRUE

```

---

**All I want of the query:** I want a column contains `true` or `false` *(just for non-free posts)* to tells me current user paid the cost of current post or not. In other word:

There is a row in `Money_paid` table which `user_id = :user_id` => `true`

There isn't any row -> `false`