You can use SUBSTRING_INDEX , which returns a substring before or after a certain number of separator occurrences.
In the example below, the space is a separator, and a number of 1 returns everything to the left of the first space and a score of -1 is everything to the right of the first space.
DELETE FROM jos_users WHERE SUBSTRING_INDEX(name, " ", 1)=SUBSTRING_INDEX(name, " ", -1)
I would first execute a SELECT to make sure there is no legit user (rarely, but this can happen)
Important note: this only works if the name is in the form <name> <surname> . The problem is with several places. In the case of several spaces (for example, <composite name> <composite name> ), you should use different account values ββ( 2;-2 3;-3 , etc.).
source share