Neat trick, and some notes

This falls under “I knew I could do this but I didn’t realize I could apply it this way!”

You can do

SELECT 1 from table1;

Which will return n rows, each row having 1 field whose value is 1. n is the number of rows in table1.

SELECT "string" from table1 works similarly.

However, I never considered using

SELECT "string" as "debug statement" to debug code.

For instance,

mysql> SELECT "SELECT foo from bar where baz>0" as "debug";;
+---------------------------------+
| debug |
+---------------------------------+
| SELECT foo from bar where baz>0 |
+---------------------------------+
1 row in set (0.00 sec)

Neat trick! This is why I follow the MySQL Users general list, because every so often a gem like this comes up. Plus, I can’t resist helping folks out. And if I’m not accurate, someone else will step up.

Some more random thoughts, as I’m thinking about them and did not really want to make a separate post for them — at the MySQL Users Conference, the rank on PlanetMySQL.com came up, from “the conference postings will increase my rank” to “so-and-so cheats and makes lots of little posts.”

Now, I was just happy to make the list. Of course, now that I did post a lot at the conference, my rank went up from about #12 to about #7. As an experiment, I’m attempting to publish an average of one post a day for May and see what my ranking is at the end of May. So far, so good. And of course, as always, all of my posts will have content!

I think it would be neat to have a little line on planetmysql.com that shows where “1 post a day”, “1 post a week” and “1 post a month” fall for the top posters.

This falls under “I knew I could do this but I didn’t realize I could apply it this way!”

You can do

SELECT 1 from table1;

Which will return n rows, each row having 1 field whose value is 1. n is the number of rows in table1.

SELECT "string" from table1 works similarly.

However, I never considered using

SELECT "string" as "debug statement" to debug code.

For instance,

mysql> SELECT "SELECT foo from bar where baz>0" as "debug";;
+---------------------------------+
| debug |
+---------------------------------+
| SELECT foo from bar where baz>0 |
+---------------------------------+
1 row in set (0.00 sec)

Neat trick! This is why I follow the MySQL Users general list, because every so often a gem like this comes up. Plus, I can’t resist helping folks out. And if I’m not accurate, someone else will step up.

Some more random thoughts, as I’m thinking about them and did not really want to make a separate post for them — at the MySQL Users Conference, the rank on PlanetMySQL.com came up, from “the conference postings will increase my rank” to “so-and-so cheats and makes lots of little posts.”

Now, I was just happy to make the list. Of course, now that I did post a lot at the conference, my rank went up from about #12 to about #7. As an experiment, I’m attempting to publish an average of one post a day for May and see what my ranking is at the end of May. So far, so good. And of course, as always, all of my posts will have content!

I think it would be neat to have a little line on planetmysql.com that shows where “1 post a day”, “1 post a week” and “1 post a month” fall for the top posters.

Comments are closed.