I have three tables:
// Posts +----+----------+---------------+-----------+ | id | title | content | id_author | +----+----------+---------------+--
INSERT INTO Votes (id_post,id_user) SELECT p.id, u.id FROM Posts p INNER JOIN Users u ON 1 = 1 WHERE p.id_user = :author AND u.id = :current_user_id AND u.active = 1 LIMIT 1;