Hello! Tell me how to use the operator IN

There is such a request "UPDATE order SET Cut_Mission_Id =% s WHERE Id IN (% s)"

Did so

 query = "UPDATE `order` SET Cut_Mission_Id = %s WHERE Id IN %s" args = (5, (5, 6)) cursor.execute(query, args) 

So

 query = "UPDATE `order` SET Cut_Mission_Id = %s WHERE Id IN (%s)" args = (5, "5, 6") cursor.execute(query, args) 

In the first case, the query does not work, in the second case only one digit is transmitted and there is only one line (it should be 2). Did not find how to do it! Help!

  • one
    I'm afraid this is a problem. either substitute values ​​in the text at once, or write IN (% s,% s,% s, ...) and transfer the individual elements of the array accordingly - Mike
  • Well, this is very strange! This is not the rarest operator) - Alexander Rublev
  • one
    At least this is how DB drivers work in all languages. There is a binding of the value , and one value in the form of text is a completely different list of several values ​​that is written in the text in IN. it would be logical if you could pass an array. But I have never heard of a database driver that allows you to transfer arrays of values ​​as one parameter - Mike
  • 2
    Personally, I prefer in such cases to generate and insert into the text question marks on the number of elements in my array for transmission (in python, of course,% s are used instead of questions) - Mike

0