--- Danny Yoo <[EMAIL PROTECTED]> wrote:
> > 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? > Hi It gives me the correct result , but I have problem in running a program in which it ask for which email to be searched , I am lost and confused there , I had marked it in my code *** import MySQLdb s_email = raw_input("Enter the Email to be searched ") db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() """ I get confused here , in the SQL statement we use %s for the searched string , here I also need to use another % for pattern matching , I get lost over here """ entry.execute("""SELECT * FROM contact WHERE email_id = %s """, (s_email,)) #entry.execute("""SELECT * FROM contact WHERE email_id like %s% """, (s_email,)) p = entry.fetchall() print p > > Best of wishes to you! > > ___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor