I know this isn’t correct, but this is basically what I want to do:
delete FROM jos_users WHERE name like '<firstname>=<lastname>'
In Joomla the name field is one input and there are a lot of spam accounts that have the same first & last name – for example Uzhuzaio Uzhuzaio – that I would like to delete.
So in summary, I need a query that will delete the users from jos_users where the name field contains 2 of the same word
You can use SUBSTRING_INDEX, which returns a substring before or after a certain number of occurrences of a delimiter.
In the example below, space is the delimiter, and a count of 1 will return everything to the left of the first space and a count of -1 everything on the right of the first space.
I would however perform a SELECT first, to see that there is no legitimate user in there (rare, but it could happen)
Important note: this only works if the name is in the form
<name> <surname>. Multiple spaces will pose a problem. In the case of multiple spaces (e.g.<composite name> <composite name>) you should use different count values (2;-23;-3etc).