3
idValue = 100
limitValue = 10000
query = "SELECT count(*) as count FROM oneTable WHERE id = (%s) LIMIT (%s)";
cursor.execute(query, (idValue, limitValue ))

This doesn't seem to be working. It fetches only 1 record corresponding to the id.

2 Answers 2

1

I think that this should work as you want. If you print result, you can see result of your query.

idValue = 100
limitValue = 10000
query = "SELECT count(*) as count FROM oneTable WHERE id = {0} limit {1}".format(idValue,limitValue)
cursor.execute(query)
result = cursor.fetchall()
Sign up to request clarification or add additional context in comments.

2 Comments

it's not working. It does the same thing as above, fetches only 1 row. Any idea why?
there should be one row that id = 1000, i think you should try to remove id filter.
1

The original query in the question does work. There was some other bug in my code and hence it ceased to work then. Thanks @Baran

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.