This blog doesn't really exist!

Please note! I no longer post content to this blog.

All the posts that you see here (plus anything else I've written since December 2009) are available at my new web site.
Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

2008-11-27

My accomplishment for the day: a MySQL quine!

Some background: a "quine" is a program that outputs it's complete source code when run.

Some more background: I work at a company where I work with MySQL (a database engine) very often.

I was lounging around in the MySQL chat room on irc.freenode.net, and someone suggested that I try to write a MySQL quine - a database query that would return the text of the query itself.

After about half an hour of screwing around, I got it! It may not be a fantastic achievement, but I feel pretty leet about writing my first quine in a database query language.

SELECT REPLACE(@v:='SELECT REPLACE(@v:=\'2\',1+1,REPLACE(REPLACE(@v,\'\\\\\',\'\\\\\\\\\'),\'\\\'\',\'\\\\\\\'\'));',1+1,REPLACE(REPLACE(@v,'\\','\\\\'),'\'','\\\''));

Only 167 characters. Hah!