Below are four ways to list out the tables in a MySQL database using SQL or the command line.
Continue readingCategory: MySQL
Fix “ERROR 1054 (42S22): Unknown column ‘…’ in ‘order clause'” when using UNION in MySQL
If you’re getting error “1054 (42S22): Unknown column ‘…’ in ‘order clause'” when using the UNION
clause in MySQL, it could be because you’re trying to reference an aliased column by its column name.
Fix “ERROR 1136 (21S01): Column count doesn’t match value count at row 1” when Inserting Data in MySQL
One of the more common error message in MySQL goes like this: “ERROR 1136 (21S01): Column count doesn’t match value count at row 1“.
This error typically occurs when you’re trying to insert data into a table, but the number of columns that you’re trying to insert don’t match the number of columns in the table.
In other words, you’re either trying to insert too many columns, or not enough columns.
Continue reading7 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 readingMySQL 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.
5 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 readingMySQL UNION Clause
In MySQL, the UNION
clause combines the results from multiple queries into a single result set.
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 reading