phpmysqljoomla

MYSQL LIKE to match part of a string


I have a query but just can not seem to get this to work.

Here is what i am speicificallly looking for inside a mysql table string

link = index.php?option=com_content&view=article&layout=custom:article&id=13

I need to do a MYSQL query that matches view=article so i can exclude rows that have that.

SELECT * FROM menus WHERE published=1 AND link LIKE '\view=\article\%'

Thnak you so much in advance

more updated code:

<field 
class="menuselections" 
name="bannerpage" 
type="sql" 
default="" 
label="Show On Menus" 
query="SELECT * FROM #__menu WHERE published=1 AND link LIKE '%\view=\article\%' AND title NOT IN('Menu_item_Root','com_joomlaupdate')" 
key_field="id" 
value_field="title" 
multiple="true" />

Solution

  • You need wildcards on both ends of the string, given the example.

    SELECT * FROM menus WHERE published=1 AND link LIKE '%view=article%'
    

    However, since you said you want to EXCLUDE them, use NOT LIKE instead.