3
"SELECT DISTINCT `Name` FROM ( SELECT * FROM `Aliases` WHERE ( `IP` GLOB 'ENTERED_NAME' ) ORDER BY `Datetime` DESC )"

Basically trying to get all the names that link to the same IP address as the "ENTERED_NAME".

Is there a MySQL equivalent to "GLOB" ?

Madbreaks
  • 19,094
  • 7
  • 58
  • 72
SAFC
  • 314
  • 1
  • 3
  • 11

2 Answers2

2

GLOB uses wildcards, eg GLOB 'Foo*' to match anything starting with Foo. Mysql doesn't support this, but you can convert your string to work with LIKE as follows:

WHERE IP LIKE BINARY REPLACE('ENTERED_NAME', '*', '%') -- replace * with %
Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • Actually, isn't the difference between `GLOB` and `LIKE` that `GLOB` is case-sensitive ? – Luatic Oct 06 '18 at 10:25
  • 1
    @LMD quite so - I’ve edited the answer to perform a [case sensitive like](https://stackoverflow.com/a/14007477/256196). – Bohemian Oct 06 '18 at 10:30
1
SELECT DISTINCT `Name` FROM (
    SELECT * FROM `Aliases` WHERE ( `IP` LIKE '%[entered_name]%' ) ORDER BY `Datetime` DESC
)

...or...

SELECT DISTINCT `Name` FROM (
    SELECT * FROM `Aliases` WHERE ( `IP` = '[entered_name]' ) ORDER BY `Datetime` DESC
)

...where [entered_name] changes accordingly.

Ian Atkin
  • 6,302
  • 2
  • 17
  • 24