As a result, you need to create a query like this.
SELECT * FROM A
WHERE (
(column1 = 1 AND column2 = 'a') OR /* "Column2 value is a when column1 value is 1" */
(column1 = 2 AND column2 = 'b') OR /* After that... */
(column1 = 3 AND column2 = 'c') /* ... You have to tie it with OR to get one of them caught. */
)
I believe that the most efficient way to do this in pymysql is to be answered by someone else, and my writing is shortened here.
Note: The query below will not work as expected. You said "where in" so just in case...
SELECT * FROM A
WHERE column1 IN (1, 2, 3)
AND column2 IN ('a', 'b', 'c')
© 2024 OneMinuteCode. All rights reserved.