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

Alan Gauld alan.gauld at freenet.co.uk
Sun Jan 29 16:27:53 CET 2006

>  I am trying to search and display the results , even
> if we  give a part of the email_id 

>        entry.execute("""SELECT * FROM contact WHERE
> email_id  =  %s """, (s_email,))

If you want to do partial matches you will need to use LIKE

SELECT * FROM contact 
WHERE email_id LIKE %s

Using = will only check for an exact match, and as you show 
that works OK.


Alan G
Author of the learn to program web tutor

More information about the Tutor mailing list