php - MySQL wildcard return only matches with hyphen and number -


I have the following lines in my database, which is a duplicate if it increases:

foo < Br> F-1
F-2
F-3
Bar
Bar-1 < / P>

I want to ask DB and want to get previous F - # . I've tried to use the operator like below:

  Select * Link where '$ slug%' object timestamp DESC limit1 ";   < P>  my problem  if $ slug == f gives foo-3 instead of f-3. Is there a better way to use% wildcard?   < P> 
  select link * Where '$ slug-%' or slug = '$ slug' order timestamp DESC limit 1   

option, if you do not have or If you want to do this, you will need to use a REGEXP match. However, you probably leave the ability to use the index for the query if you do this.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -