As many of you know that this blog runs on Wordpress and under the hood of Wordpress there is a MySQL database. MySQL database is quite good and is able to hold massive traffic this blog receives every day. However, just like any database MySQL needs tuning as well as proper management of the same. In this blog post we will discuss about how I received a very weird error Wordpress Database Error and how I resolved it.
There are so many different databases in the world and many of them use the language SQL for their programming. It is very easy to assume that if they are using SQL, we can easily use code from one database to another database. Unfortunately the reality is very different, not all the scripts from one database works in another database. Today we will see very interesting question where the user asked a question about inserting multiple rows in a single SQL query.
The biggest challenge which we often face as a database person is to compare the value across multiple columns. Trust me, if there were no comparison operators, we would have never got this task done. MySQL supports many comparison operators like BETWEEN, IN, etc. LEAST and GREATEST is very handy if you want to compare values across many columns.
In SQL Server to get the total number of rows affected by the last statement, you can use the system variable @@ROWCOUNT. Similarly, in MySQL you can find it using FOUND_ROWS () function.
There are different methods to know the name of the current user in MySQL. There can be many reasons we want to know who is the current user. Here is list of the of the few of the such reasons.
Customized code which we want to run based on the reason.
Checking the permissions based on the user.
Inserting the name of the user in the audit table.
Displaying special message based on the login user.
Executing some special logic/code based on the logged in user.
In this post SQL Server – 2016 – T-SQL Enhancement “Drop if Exists” clause, we have seen the new feature introduced in SQL Server version 2016. One of my friends recently asked me question that how to drop table in exists in MySQL database? It was not surprising to see that not many people know about the existence of this feature. MySQL already has this feature for a while and if you are MySQL DBA, you may find it interesting that SQL Server just introduced this feature.
MySQL supports some functions that can be used to extract the index position or the actual value from a set of values arranged as an array. ELT() and FIELD() are example of such functions. Let us understand about them in details.