Whether the intercepted string can be treated directly as a where condition in the SQL statement
For example, this
Select ' id ' from ' table ' where left (' flag ', 1) = 1;
I have a list of flags named flag used to represent various attributes of the commodity, 10-digit int, for example 1100000000.
Then for example the first number 1 indicates that the price range of the commodity is 100-200 yuan.
And then I want to pick out the flag from the table and take out the first number of 1 items.
Can this be achieved, just using MySQL mysql
Share to:
------Solution--------------------
Select ' id ' from ' table ' where left (' flag ', 1) = ' 1 '
------Solution--------------------
Your SQL, isn't it??
------Solution--------------------
Performance should be less of a function.
------Solution--------------------
As long as the left side of the matching string like is not a variable, then you can use the index
For 1,2,11, so it's 1,11,2.
Like ' 1% ' is always quick to take out 1, 11, as they gather together