For the SQL field "include" and "include" string
Zookeeper
1. Method for querying all records whose field value "contains" a string
If the table has a name field and the query name contains all records of "Zhang San", you can write the SQL statement as follows:
Stirng strsql = "SELECT * FROM table name WHERE name LIKE '%" + "Zhang San" + "% '";
2. How to query all records with a field value "included in" a string
If the name field in the query table contains all the records of the string "John is a good student", you can write the SQL statement as follows:
String strsql = "SELECT * FROM table name where instr ('John is a good student ', name)> 0 ";
You can query all the records. The name field values in the record include: sheet, 3, yes, item, good, student, student, Michael, and so on.
Note: In the preceding SQL string, change the fullwidth symbol to the halfwidth symbol.
How to include SQL query field values in strings
Can't I use charindex? In fact, it is very simple. Your logic is that the returned data should be found in the string you provide. You can see if this is the case:
Select * from
Where
CHARINDEX (substring (value, 1, 1), 'a, B, d, e') <> 0
And
CHARINDEX (substring (value, 2, 1), 'a, B, d, e') <> 0
And
CHARINDEX (substring (value, 3, 1), 'a, B, d, e') <> 0
In SQL statements, how do I write a statement that finds a field containing a string?
Select filename from oa_file where filename like '%? % ';
You must have no problem with this sentence. The possible problem is that the question mark is different from the question mark!
For example, the question mark at the halfwidth of an English Punctuation Mark is "?", The question mark of the English Punctuation is "?"
But the question mark in Chinese is "?" Question mark (?)
These are different. All the files you found contain English question marks.
The above is my idea.