通配符

  1. import mysql.connector
  2.  
  3. mydb = mysql.connector.connect(
  4. host="localhost",
  5. user="myusername",
  6. passwd="mypassword",
  7. database="mydatabase"
  8. )
  9.  
  10. mycursor = mydb.cursor()
  11.  
  12. sql = "SELECT * FROM customers WHERE address Like '%way%'"
  13.  
  14. mycursor.execute(sql)
  15.  
  16. myresult = mycursor.fetchall()
  17.  
  18. for x in myresult:
  19. print(x)