In MySQL, the UNION
clause combines the results from multiple queries into a single result set.
Category: DBMS
Database Management Systems
3 Ways to Select the Row with the Minimum Value in SQL
Here are three examples of using SQL to find and select the row with the minimum value in a given column.
The examples work in most major RDBMSs, including MySQL, MariaDB, PostgreSQL, SQLite, Oracle, and SQL Server.
Continue readingSHOW TABLES in MariaDB
In MariaDB, SHOW TABLES
is an administrative statement that lists the non-TEMPORARY
tables, sequences and views in a given database.
Oracle INTERSECT Operator Explained
In Oracle Database, the INTERSECT
operator is used to create a compound query that returns the intersection of the results of the left and right SELECT
statements. In other words, it combines two queries, but returns only those rows that are returned in both queries.
6 Ways to Select Duplicate Rows in Oracle
The following examples return duplicate rows from an Oracle Database table.
Continue readingFix “ERROR: missing FROM-clause entry for table” in PostgreSQL when using UNION, EXCEPT, or INTERSECT
If you’re getting “ERROR: missing FROM-clause entry for table” in PostgreSQL when using an operator such as UNION
, INTERSECT
, or EXCEPT
, it could be because you’re qualifying a column name with its table name.
To fix this, either remove the table name or use a column alias.
Continue readingOracle MINUS Operator Explained
In Oracle Database, the MINUS
operator is used to return only unique rows returned by the first query but not by the second.
4 Ways to Find Rows that Contain Uppercase Letters in Oracle
Here are four options for returning rows that contain uppercase characters in Oracle Database.
Continue readingFix “ERROR: each UNION query must have the same number of columns” in PostgreSQL
When using the UNION
operator in PostgreSQL, if you encounter an error that reads “ERROR: each UNION query must have the same number of columns“, it’s because there’s a mismatch in the number of columns returned by the queries on either side of the UNION
operator.
This error occurs when the number of columns returned by each SELECT
statement is different.
The way to fix this is to ensure that both SELECT
statements return the same number of columns.
How UNION Works in PostgreSQL
In PostgreSQL, the UNION
operator combines the results from multiple queries into a single result set.