SELECT * FROM multiple tables. MySQL

What you do here is called a JOIN (although you do it implicitly because you select from multiple tables). This means, if you didn’t put any conditions in your WHERE clause, you had all combinations of those tables. Only with your condition you restrict your join to those rows where the drink id matches. But … Read more

Difference between two dates in MySQL

SELECT TIMEDIFF(‘2007-12-31 10:02:00′,’2007-12-30 12:01:01′); — result: 22:00:59, the difference in HH:MM:SS format SELECT TIMESTAMPDIFF(SECOND,’2007-12-30 12:01:01′,’2007-12-31 10:02:00’); — result: 79259 the difference in seconds So, you can use TIMESTAMPDIFF for your purpose.

How to see log files in MySQL?

Here is a simple way to enable them. In mysql we need to see often 3 logs which are mostly needed during any project development. The Error Log. It contains information about errors that occur while the server is running (also server start and stop) The General Query Log. This is a general record of … Read more

Run MySQLDump without Locking Tables

Does the –lock-tables=false option work? According to the man page, if you are dumping InnoDB tables you can use the –single-transaction option: –lock-tables, -l Lock all tables before dumping them. The tables are locked with READ LOCAL to allow concurrent inserts in the case of MyISAM tables. For transactional tables such as InnoDB and BDB, … Read more