themaestro
themaestro

Reputation: 14256

Trouble Querying Against int Field using MYSQL

Hey, I'm trying to run the following query:

     self.cursor.execute('SELECT courses.courseid, days, starttime, bldg, roomnum, '
                    'area, title, descrip, prereqs, endtime FROM '
                    'classes, courses, crosslistings, coursesprofs, profs WHERE '
                    'classes.courseid = courses.courseid AND '
                    'courses.courseid = crosslistings.courseid AND '
                    'courses.courseid = coursesprofs.courseid AND '
                    'coursesprofs.profid = profs.profid AND '
                    'classes.classid LIKE %s'
                    ';',
                    (self.classid))

classid is an int(11) field in the db. When I set self.classid = %, it returns all the results, but as soon as I set it to say, '3454' or some other amount it returns nothing even when there is a class with that classid. Am I querying incorrectly against int fields?

Even a simpler query like select * from classes where classes.classid = '3454'; does not work

Upvotes: 0

Views: 148

Answers (2)

themaestro
themaestro

Reputation: 14256

I resolved this on my own. Based on my db structure, I was querying the wrong fields. I was looking for values that weren't there so that's why I was always returning an empty result set. Thanks for the help on the = operator though, that was utilized.

Upvotes: 0

Maarten Terpstra
Maarten Terpstra

Reputation: 426

Try:

select * from classes where classes.classid = 3454;

Upvotes: 2

Related Questions