Employing IF Statements with LIKE Operator in MySQL

To retrieve all records from the tutorials_tbl table where the author name ends with “jay,” one can use the LIKE clause in a PHP script. This can be achieved by using the mysqli_query() or mysql_query() function to select records from a MySQL table with the LIKE clause, which can be combined with the WHERE clause […]

Selecting SQL without Grouping by SQL

Your desired output, which groups data by ID and displays name, is not an improvement over your incorrect output that groups data by name. This is because although you now know that one lecturer taught two modules and the other taught one, you cannot determine which lecturer is which. The optimal output would be to […]

Adding a Condition in a MySQL Table Column

There are two solutions available. The first solution is not described. For the second solution, a MySQL query can be used for a multiple select field. One can use either if…else statements or a case statement. An example trigger is also provided for this column when inserting new rows. However, since this information is subjective […]

Triggering Mysql to Update the Same Table upon Insert

If you want to avoid using the same table with triggers, you could consider using a different algorithm. However, it’s important to keep in mind that triggers come with many limitations when creating a new system. Alternatively, you could implement a second table as a solution. It’s worth noting that column values cannot be altered […]

Count records where column is not null using a single query

Feedback Solution 1: COUNT(expr) Provides a tally of the quantity of non-NULL values for expr in the rows obtained through a SELECT statement. The ensuing inquiry will provide tallies of non-null values for every column. SELECT COUNT(*) AS Total, COUNT(X_N) AS NNC_N, COUNT(X_Pad) AS NNC_Pad FROM table; Obtain the list of corresponding columns in a […]

Transforming Boolean Values from Rows to Columns using MySQL

Feedback Question: My goal is to create an SQL statement specifically designed for MySQL to address the issue at hand. I possess a table called “transport_table” that contains data about the locations from which transports originate and the destinations to which they are sent. The table is sorted in ascending order based on the transport_from […]

Finding the Port for Mariadb Server

Feedback Question: I want to connect to VM server Here is server IP: MariaDB’s port = 3306 I used this command: mysql -uroot -p123456 -h203.64.1.2:8080 -P3306 It showed : ERROR 2005 (HY000): Unknown MySQL server host ‘’ (11001) If I use this: mysql -uroot -p123456 -h203.64.1.2 -P8080 show this: ERROR 2013 (HY000): Lost connection to […]