You can use a database engine module for Garry’s Mod. The two most prominent options are tmysql4, which is no longer maintained but still works fine if you structure your queries to never be order-reliant if not called in order-by-callback; and mysqloo9 which is more of the standard and is still maintained. Both have their own separate syntaxes but create objects for the database where you can run queries.
[editline]3rd November 2017[/editline]
Alternatively, you can use the built-in SQLite library, but these can only be accessed by the Lua state and no outside applications/websites.