By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,539 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,539 IT Pros & Developers. It's quick & easy.

python & mysql probelm

P: n/a
Hi
I am having a problem executing following query:
cursor.execute("select * from projects where projectid between '%s'
and '%s'"%(id1,id2))
But say if i have projectid's from 1 to 20 in database & if i give the
project range 1 to 2 then it gives me the result 1,2,11,12,13,14.....
When I execute this query in mysql i.e
select * from projects where projectid between 1 and 2,I get the
correct result.
I also tried doing
cursor.execute("select * from projects where projectid between '%s'
and '%s'"%(int(id1),int(id2))
but no success
What should I do??
Regards,
James
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
james blair wrote:
Hi
I am having a problem executing following query:
cursor.execute("select * from projects where projectid between '%s'
and '%s'"%(id1,id2))
But say if i have projectid's from 1 to 20 in database & if i give the
project range 1 to 2 then it gives me the result 1,2,11,12,13,14.....
When I execute this query in mysql i.e
select * from projects where projectid between 1 and 2,I get the
correct result.
I also tried doing
cursor.execute("select * from projects where projectid between '%s'
and '%s'"%(int(id1),int(id2))
but no success
What should I do??
Regards,
James


James,
As strings 11 is less than 2. Are your fields strings
or ints? If you change them from strings to ints, mysql
will make the translation.
wes

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.