If you’ve got a Redis hash with a field that needs to be deleted, you can use the HDEL
command.
Tag: how to
Fix “ERR syntax error” when calling SRANDMEMBER in Redis
If you’re getting an error that reads “ERR syntax error” when calling the SRANDMEMBER
command in Redis, it could be that you’re passing too many arguments.
To fix this issue, be sure to pass the correct number of arguments. At the time of writing, SRANDMEMBER
accepts up to two arguments. Any more than this results in an error.
4 Ways to Insert a Field in a Redis Hash
I decided to compile a list of commands that can insert a new field into a Redis hash. Here are four options for inserting a new field into a Redis hash.
Continue readingFix “WRONGTYPE Operation against a key holding the wrong kind of value” when using SMEMBERS in Redis
If you get an error that reads “WRONGTYPE Operation against a key holding the wrong kind of value” when using the SMEMBERS
command in Redis, it’s probably because you’re passing a key with the wrong data type to the command.
The SMEMBERS
command is a “set” command, and so it is intended to be used on keys that contain a set. If the key holds a different data type, you’ll likely get the above error.
3 Ways to Check if a Table has a Generated Column in SQLite
If you’re not sure if a table has a generated column in SQLite, you can quickly find out with either the .schema
command, or by querying the sqlite_schema
table.
Fix “ERR numkeys should be greater than 0” when using the SINTERCARD Command in Redis
If you’re getting an error that reads “ERR numkeys should be greater than 0” in Redis, it’s probably because you’re specifying a wrong value for the first argument when calling the SINTERCARD
command.
To fix this issue, make sure you’re passing a valid non-zero value that matches the number of keys you’re comparing.
Continue reading5 Ways to Create a Table in SQL
Probably the most common way of creating a table in SQL is to use a basic CREATE TABLE
statement, along with the table’s definition. But that’s not the only way of doing it.
Below are five options for creating a table when using SQL.
Continue reading7 Ways to Insert Multiple Rows in SQL
We can use the SQL INSERT
statement to insert a row into a table. We can also use it to insert more than one row.
Below are seven ways to insert multiple rows into a table in SQL. Most of these examples should work in the major RDBMSs, with the possible exception of Oracle. But no worries, I’ve included an example just for Oracle.
Continue readingFix “One or more scores can’t be converted into double” when using SORT or SORT_RO in Redis
If you’re getting an error that reads “One or more scores can’t be converted into double” when using either the SORT
or SORT_RO
commands in Redis, it could be because you omitted the ALPHA
modifier when trying to sort string values.
If you want to sort string values lexicographically, you need to use the ALPHA
modifier when using the SORT
or SORT_RO
command.
Add Minutes to a Time Value in SQLite
In SQLite, we can use the TIME()
function to add a given number of minutes to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.