S
S
sorry_i_noob2018-07-06 19:55:53
MySQL
sorry_i_noob, 2018-07-06 19:55:53

MySQL - You can find long records from the database by short ones - using LIKE and %. Is it possible vice versa? Find a short record in the database by the long one?

I have the following line in the database:
/seo
I need to /seo/newsget it from this. How can I do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zxscv, 2018-07-06
@sorry_i_noob

$query = 'SELECT * FROM seo WHERE LOCATE(url, '/seo/news')=1';

B
bedward70, 2018-07-06
@bedward70

And what's the problem: you swap the value and the field (you can add special characters to the field to determine how you plan to search). As an example:

SELECT value FROM setting WHERE '/seo/news' LIKE '%' || value || '%'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question