In SQLite, the UNION
operator creates a compound SELECT
statement that returns the results of the left and right SELECT
statements. In other words, it combines the results from two queries into a single result set.
Category: DBMS
Database Management Systems
7 Ways to Find Duplicate Rows while Ignoring the Primary Key in MySQL
Here are seven ways to return duplicate rows in MySQL when those rows have a primary key or other unique identifier column.
Continue readingFix “ERROR 1054 (42S22): Unknown column ‘colname’ in ‘order clause'” in MariaDB
If you’re getting error “ERROR 1054 (42S22): Unknown column ‘colname’ in ‘order clause’” in MariaDB, it may be that you’re trying to reference an aliased column by its column name.
This is a common error when running queries that join two or more tables. It can also happen when using operators such as UNION
, INTERSECT
, and EXCEPT
.
MySQL TABLE Statement
In MySQL, the TABLE
statement returns rows and columns of the given table.
The TABLE
statement is similar to the SELECT
statement, and it can be used as a kind of shorthand version of the SELECT
statement.
The TABLE
statement was introduced in MySQL 8.0.19.
VALUES Statement in MySQL
In MySQL, the VALUES
statement returns a set of one or more rows as a table. Basically, it’s a table value constructor in accordance with the SQL standard, which also functions as a standalone SQL statement.
The VALUES
statement was introduced in MySQL 8.0.19.
SHOW TABLES in MySQL
In MySQL, SHOW TABLES
is an administrative statement that lists the non-TEMPORARY
tables and views in a given database.
SHOW TABLES
only lists the tables and views for which you have privileges.
2 Ways to Return Rows that Contain Only Alphanumeric Characters in MariaDB
Below are two methods for returning rows that only contain alphanumeric characters in MariaDB.
Alphanumeric characters are alphabetic characters and numeric characters.
Continue readingFix Error “ORA-01790: expression must have same datatype as corresponding expression”
If you’re getting the error “ORA-01790: expression must have same datatype as corresponding expression” in Oracle Database, it’s probably because you’re using an operator such as UNION
, INTERSECT
, or EXCEPT
to run a compound query, but the columns returned by each query use different data type groups.
To fix this issue, you’ll need to ensure that each column returned by the second query uses the same data type group as the corresponding column in the first query.
Continue reading5 Ways to Select Rows with the Minimum Value for their Group in SQL
Here are five options for using SQL to return only those rows that have the minimum value within their group.
These examples work in most major RDBMSs, including MySQL, MariaDB, Oracle, PostgreSQL, SQLite, and SQL Server.
Continue readingFix Error 1064 (42000) when using the MINUS Operator in MariaDB
There are at least a few possible reasons you might be getting the dreaded error 1064 (42000) that reads “You have an error in your SQL syntax…” etc when trying to use the MINUS
operator in MariaDB.
I’ll explore these below and offer some solutions.
Continue reading