1 year ago
#71981

Matt Perry
Quickbooks and pyodbc LIKE pattern matching
I'm using pyodbc to run some queries against Quickbooks and having some issues with pattern matching, specifically with square bracket wildcards. I don't even know if I'm allowed to use square bracket wildcards or where I would go to find that answer. The pyodbc docs don't show any examples using them from what I can see. The only wildcard that seems to work that I've tried is %.
I'm trying to build a pattern to match on these two strings:
- M-100
- J-100
This is the query that is returning no rows:
cursor.execute("SELECT ListID,FullName from ItemInventoryAssembly WHERE Name LIKE ?", '[MJ]-100')
These queries do return rows:
cursor.execute("SELECT ListID,FullName from ItemInventoryAssembly WHERE Name LIKE ?", 'M-100')
cursor.execute("SELECT ListID,FullName from ItemInventoryAssembly WHERE Name LIKE ?", 'J-100')
Do I have to use the following instead of [] wildcards? (I have many more names to match on and this query would end up being very long and ugly.)
cursor.execute("SELECT ListID,FullName from ItemInventoryAssembly WHERE Name LIKE ? OR Name LIKE ?", ('M-100','J-100'))
Additionally, where would I go to find which wildcards I'm allowed to use in my setup with pyodbc and Quickbooks?
pyodbc
quickbooks
0 Answers
Your Answer