[Tutor] Searching for email id in MySQL giving wrong results

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sun Jan 29 12:12:27 CET 2006


> the email id which starts with “j”  is
> select * from contact where email_id like 'j%';

Hi John,

Ok, looks good so far.  So in a Python program, we might try something
like this:

##############################################################
                        ## assuming cursor is set up properly:
cursor.execute("select * from coutact where email_id like %s",
               ("j%",))
print cursor.fetchone()
##############################################################

Try an example off the interactive interpreter prompt.  Do you get the
results you expect?


Best of wishes to you!



More information about the Tutor mailing list