[Tutor] Searching for email id in MySQL giving wrong results
ZIYAD A. M. AL-BATLY
zamb at saudi.net.sa
Sun Jan 22 19:23:23 CET 2006
On Sun, 2006-01-22 at 12:43 +0000, John Joseph wrote:
> Hi
Hi John...
Most of your problems in your code seems to be caused by a single
mistake. Compare the following two strings and you should figure out
what's wrong by yourself:
email_id = 'email at domain.tld'
wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id)
right_string = '''SELECT s FROM t WHERE id=%s''' % (email_id)
print "Wrong:", wrong_string
print "Right:", right_string
This is the output:
Wrong: ('SELECT s FROM t WHERE id=%s', 'email at domain.tld')
Right: SELECT s FROM t WHERE id=email at domain.tld
Now, which one is the right one? And which one is the one you want?
I suggest you study strings more, especially concatenation and '%'.
If you need more help, just post to the mailing list again.
Ziyad.
More information about the Tutor
mailing list