title: Python/ PonyORM /MySQL - Query using multiple URL Args
body: <p>I have a URL <a href="https://example.com?p1=nai&amp;p2=tex&amp;p3=mak" rel="nofollow noreferrer">https://example.com?p1=nai&amp;p2=tex&amp;p3=mak</a></p>
  
  <p>I am using PONY ORM + Flask, on MYSQL. I would like to get all rows that match the URL parameters. The p1, p2 and p3 are fields on the table and can vary depending on user input</p>
  
  <p>In MySQL I would have something like done [SELECT * FROM Table Name WHERE p1=nai&amp;p2=tex]</p>
  
  <p>Below my PONY/Flask code</p>
  
  <pre><code>query = select(r for r in Route)
  for key,value in args.items():
      query = query.where("lambda r: r.%s == '%s'" %(key, value))
      print(r.id)
  </code></pre>
  
  <p>My query above just returns a match for the first parameter. i.e if p1 = nai then it will return all where p1= nai and ignore the rest. What am I missing? NB: Don't worry about SQL Injection</p>