Jump to content

Recommended Posts

Posted (edited)

Trying to create a dataset on our internet reporting software which is all done in SQL.

 

Trying to grab google searches with specific words in them. So for example if i use keyword = 'bum' , the search phase 'pokey bum w**k' won't be matched as its looking for exactly the word bum. So i did keyword LIKE '%bum%' and it matches, but so does the word album which is not what i am after. So then i though what about putting a space either side so its keyword LIKE '% bum %' which works for pokey bum w**k, but fails when i then do keyword LIKE '% gay %' if gay is the first word as it does not start with a space.

 

Is there a way in SQL to match any whole words in a string? (and yes the kids have been searching for pokey bum w**k )

Edited by elsiegee40
Language please!
Posted (edited)

Furthering my answer, rather than using LIKE use REGEXP i.e this may work:

REGEXP '[[:<:]]bum[[:>:]'
though I haven't tested.

 

The [[:<:]] and [[:>:]] are word boundaries.

Edited by Arreks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...