Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991

Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993

Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:4991) in /www/htdocs/v030397/mysql-qotd/wp-includes/feed-rss2.php on line 8
MySQL Question of the Day » general http://mysql-qotd.casperia.net mysql 5.0/5.1 questions for learning purposes Fri, 06 Aug 2010 16:42:05 +0000 http://wordpress.org/?v=abc en hourly 1 More uncommon SQL http://mysql-qotd.casperia.net/archives/560 http://mysql-qotd.casperia.net/archives/560#comments Sun, 25 Jul 2010 19:55:11 +0000 plogi http://mysql-qotd.casperia.net/?p=560 Hi again!
The query below uses quite a bit of strange looking SQL syntax:
select all
  count(1) minus
union all
  select 1 only
order by 1 limit 1  ;

+-------+
| minus |
+-------+
|     1 |
+-------+
1 row in set (0.00 sec)


 
The “ALL” in the “SELECT ALL” is actually the default – so you hardly ever see it.
“COUNT(1)” is mostly used with Oracle, where it may have a performance benefit over “COUNT(*)”. The result however is the same than “COUNT(*)”.
The “minus” and “only” are column aliases.
Last but not least, the “ORDER BY 1″ means, that we order by the first column.

Below the same slightly more readable:

select
  count(*) as cnt
union all
  select 1
order by cnt limit 1  ;

]]>
http://mysql-qotd.casperia.net/archives/560/feed 0
Uncommon SQL 3 http://mysql-qotd.casperia.net/archives/556 http://mysql-qotd.casperia.net/archives/556#comments Wed, 21 Jul 2010 16:57:33 +0000 plogi http://mysql-qotd.casperia.net/?p=556 select * from vending_price where (price,product_id) = any (select max(price),product_id [...]]]> Hello!
The following query does the same than yesterday’s, featuring another syntax which isn’t used that often.
MariaDB [tt]> select * from vending_price
where (price,product_id) = any (select max(price),product_id
                                            from vending_price
                                            group by product_id);

The “ANY/ALL” syntax can be very intuitive for some queries… Unluckliy not for this example %)

]]>
http://mysql-qotd.casperia.net/archives/556/feed 0
Uncommon SQL 2 http://mysql-qotd.casperia.net/archives/553 http://mysql-qotd.casperia.net/archives/553#comments Tue, 20 Jul 2010 14:19:18 +0000 plogi http://mysql-qotd.casperia.net/?p=553 select * from vending_price where (price,product_id) in (select max(price),product_id [...]]]> Hi again!
Continuing the example from yesterday, the following query shows the the real power of that syntax:
MariaDB [tt]> select * from vending_price where (price,product_id) in
                      (select max(price),product_id
                       from vending_price group by product_id);

]]>
http://mysql-qotd.casperia.net/archives/553/feed 0
Uncommon SQL http://mysql-qotd.casperia.net/archives/549 http://mysql-qotd.casperia.net/archives/549#comments Mon, 19 Jul 2010 19:03:49 +0000 plogi http://mysql-qotd.casperia.net/?p=549 Hi!
There are some useful SQL structures, which are not so commonly used. For example I like the following syntax:
select * from vending_price where (product_id,valid_from) = (0,'2010-01-09');


It is basically the same than the following, but more compact and easier to read.

select * from vending_price where product_id = 0 and valid_from  =  '2010-01-09';

]]>
http://mysql-qotd.casperia.net/archives/549/feed 0
No questions for a while http://mysql-qotd.casperia.net/archives/543 http://mysql-qotd.casperia.net/archives/543#comments Wed, 14 Jul 2010 18:42:32 +0000 plogi http://mysql-qotd.casperia.net/?p=543 Hi!
I won’t be able to post questions for a while…
Lots of things to do and everybody else is on holiday.
And then soon I’ll be on holiday :)

CU!

]]>
http://mysql-qotd.casperia.net/archives/543/feed 0
End of Product Lifecycle. http://mysql-qotd.casperia.net/archives/499 http://mysql-qotd.casperia.net/archives/499#comments Fri, 25 Jun 2010 18:09:35 +0000 plogi http://mysql-qotd.casperia.net/?p=499 Hello!
The questions until now have been based on Mysql 5.0.
But as the active development/support for 5.0 has ended already some time ago, we’ll now switch to Mysql 5.1/MariaDB 5.1.
 
Not to worry, if you have 5.0 in production. There is still extended support. Check: http://www.mysql.com/about/legal/lifecycle/#calendar

]]>
http://mysql-qotd.casperia.net/archives/499/feed 0
Short break! http://mysql-qotd.casperia.net/archives/496 http://mysql-qotd.casperia.net/archives/496#comments Thu, 24 Jun 2010 14:57:12 +0000 plogi http://mysql-qotd.casperia.net/?p=496 Hi!
There won’t be any questions for some days from me because
I’ll be busy with non-digital matters: Midsummer :)

See you again after June 29th!

]]>
http://mysql-qotd.casperia.net/archives/496/feed 0
Short break http://mysql-qotd.casperia.net/archives/470 http://mysql-qotd.casperia.net/archives/470#comments Sun, 13 Jun 2010 19:23:50 +0000 plogi http://mysql-qotd.casperia.net/?p=470 Hi!
 
No questions for a short while…
But we’ll continue soon with the subject “Backups”.
So have a look at mysqlhotcopy, ibbackup, mysqldump etc to be prepared!
 
CU soon!

]]>
http://mysql-qotd.casperia.net/archives/470/feed 0
How MySql uses disk space http://mysql-qotd.casperia.net/archives/445 http://mysql-qotd.casperia.net/archives/445#comments Tue, 08 Jun 2010 17:47:00 +0000 plogi http://mysql-qotd.casperia.net/?p=445 Hello again!
The next few questions are about MySql’s structure on disk:
- Where to find databases
- Where to find tables
- Where to find logs

You’ll need that knowledge for example to implement backups, data transfer and debugging.

]]>
http://mysql-qotd.casperia.net/archives/445/feed 0
MySql Certfication http://mysql-qotd.casperia.net/archives/439 http://mysql-qotd.casperia.net/archives/439#comments Mon, 07 Jun 2010 19:00:53 +0000 plogi http://mysql-qotd.casperia.net/?p=439 Hello!
If you attempt to pass the MySql certification tests, then check the link below!

http://www.mysql.com/certification/candguide.html

In my experience you get the practical knowledge needed for the tests quite quickly by just using MySql every day. For the theoretical background however you need to study.

I got my certifications about a hundred years ago. In preparation I visited a course. At the course I actually got vouchers for the tests and the study guide. Shortly after that I passed the certificaton tests.

So, if you are serious about MySql certifications, get the study guide. A MySql course will help you save you time on perparations. And maybe even testing your knowledge with the questions on this page will help you on the way…

]]>
http://mysql-qotd.casperia.net/archives/439/feed 0