Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the MySQL equivalent of this SQLite code?

Tags:

sqlite

mysql

glob

"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" ?

like image 562
SAFC Avatar asked Jan 31 '26 11:01

SAFC


1 Answers

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 %
like image 138
Bohemian Avatar answered Feb 02 '26 03:02

Bohemian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!