Check if mySql table attribute contains a string

Hello, im finding difficult to Google this and find an answer to my problem. Though the code must be not too complicated Im still unable to find a solution. So if any quick answers jump to your mind I would very much appreciate your help.

Ok, no need saying Im new to this but to cut a long story short :slight_smile: I need to make a simple search system. In the mySql select statement I want to select not a a field inside a table that matches exactly a string but all the records that contain that string.

Thank you all, always!

Still unsure as to what you are after but, i’ll give it a go.

I suggest you read through this article :

The SQL query below will search a table and rank results based off the number of occurrences of a string in the search fields:

    SUM(((LENGTH(p.body) - LENGTH(REPLACE(p.body, 'term', '')))/4) +
        ((LENGTH(p.body) - LENGTH(REPLACE(p.body, 'search', '')))/6))
    AS Occurrences
    posts AS p
    Occurrences DESC

Try use the percentage symbol before and after your string and mysql will search all the records which has that string on that field, not necessarily the exact only string, but consist of it. Query sample:

SELECT * FROM table WHERE field LIKE '%string%';

Thamk you both for the useful replies!