PHP查询语句3表加入

I am quite stuck with one query statement.

I have the current query:

$user_id = $_SESSION["user_id"];

$stm = $db->prepare("SELECT votes.hasVoted
FROM votes 
INNER JOIN posts
    ON posts.post_id = votes.post_id 
INNER JOIN users
    ON users.users_id = votes.user_id 
    WHERE users.user_id = :user_id;");
$stm->bindParam(':user_id', $user_id);
$stm->execute();
$votes = $stm->fetchAll();

It is not working.

I have 3 tables. [Votes, Posts, Users]. I want to retrieve 'hasVoted' value from Votes table according to the session variable of the logged in user.

Votes Table:

https://i.stack.imgur.com/ZsHZc.png

Posts Table:

https://i.stack.imgur.com/piLPu.png

Thanks in advance.

What I need help with: In my code I want to check if a logged in user is has voted on a specific post, if yes then the button will turn unclickable.

I have 3 connected Tables.

Votes Table has:
vote_id [PK]
user_id [FK]
post_id [FK]

Posts Table has:
post_id [PK]
user_id [FK]

Users Table has:
user_id [PK]

I want to interconnect them with Votes so I can access post_id and user_id from Votes