In my database I have an entry ABCCBAA
And my Query looks like this:
string sql = SELECT * FROM signatures WHERE length(signature) BETWEEN 6 AND 8 AND signature LIKE ABCCBAA
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE _BCCBAA
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE A_CCBAA
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE AB_CBAA
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE ABC_BAA
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE ABCC_AA
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE ABCCB_A
OR length(signature) BETWEEN 6 AND 8 AND signature LIKE ABCCBA_
I am searching through a lot of records with this 1 query so pardon the overkill.
I've been trying this query against the W3Schools examples and it works fine when put into context. I know I'm using SQLite and not SQL but not fully there yet with the syntax.
I expect any of those OR statements to fetch the result, but I have not even been able to execute it yet because of syntax errors. At the moment I am getting
"SQL logic error or missing database
no such column: ABCCBAA"
Why it is using it as a column name? Other examples lead me to believe the query is correct.
I've been playing about with this for a long time now, so it's possibly something simple I'm not grasping correctly.
_matches a single character, so your query can never match something of a different length.