Archives

The List

« DATABASE() :: MySQL Function of the Day | Main | PHP array_merge is Slow »

MySQL Pop Quiz #27

By Carsten | April 29, 2008

I’m still looking for new entries. I get quite a few suggestions, but not all of them make it into quiz questions. Do send in your suggestions!

This wonderful quiz from Vladimir Kolesnikov is one of those that should make you stop and think for a moment…

Given this table and data:

mysql> SELECT * FROM t;
+------+------+
| i1   | i2   |
+------+------+
|    1 |    2 |
|    2 |    1 |
|    4 |    3 |
|    3 |    4 |
+------+------+
4 rows in set (0.00 sec)

What is the result of the following three statements?

SELECT * FROM t ORDER BY 1
SELECT * FROM t ORDER BY 2
SELECT * FROM t ORDER BY 1+1

Show answer


Do you have your own favorite MySQL question? Is there something in MySQL that has you scratching your head? Send your ideas for new pop quiz questions to carsten (at) bitbybit (dot) dk. Send it in, even if you don’t know the answer — that only makes it more interesting.
More Pop Quiz entries: WWW or RSS.

Topics: MySQL, Pop Quiz |

3 Responses to “MySQL Pop Quiz #27”

  1. Brian Papantonio Says:
    April 29th, 2008 at 4:23 pm

    It might be more fun if you didn’t post the answers to the quizes until later, like the next day.

    Just a thought.

  2. Carsten Says:
    April 29th, 2008 at 5:02 pm

    Brian, thanks for the comment. I’ll try that with the next couple of quizzes and see how it’s received.

  3. Trucs MySQL : copie et tri de tables Says:
    May 2nd, 2008 at 5:35 pm

    [...]  MySQL Pop Quiz #27 (0 visite) [...]

Comments