Nicolas Manzini
Nicolas Manzini

Reputation: 8546

MySQL insert INTO a select count

I'm trying to insert a select count like this is it possible because It doesn't seems to work.

INSERT INTO vote (uid, pid, poid, yes, no, total) 
VALUES (:uid,:pid,:poid,0,0,(SELECT COUNT(*) FROM member WHERE pid = :pid2 AND type > 0))

Okay well actually this will work. I made a mistake somewhere else. This work.

Upvotes: 1

Views: 1752

Answers (1)

Try this:

INSERT INTO vote (uid, pid, poid, yes, no, total) 
SELECT :uid,:pid,:poid,0,0,COUNT(*) 
FROM member WHERE pid = :pid2 AND type > 0

Upvotes: 1

Related Questions