Home My program reads 0 from the database even though there is a 1
 I don't understand whats wrong with the code, I have read a lot of times but I can't find the error pstmt = con->prepareStatement("SELECT (?) FROM votos WHERE id = (?)"); pstmt->setString(1, eleccion); pstmt->setInt(2, p->getId()); res = pstmt->executeQuery(); while(res->next()) { p->setVoto(res->getInt(1)); }  When the eleccion and id variables are Provincial and 1 respectively the getInt(1) function should return 1, but it returns 0. The command (in the mysql command line): SELECT Provincial from Votos WHERE id=1 Returns a table with one row and one column with the value 1 Side notes: Spelling was checked The getId() function works correctly The compiler doesn't give any error