Top n Window Function queries in MySQL

Top n Window Function queries over a specific subset of data are common in analysis and reporting requirements. Luckily, in MySQL, there are Window functions we can use for this type of query. To be quite honest, you don’t necessarily need Window Functions. You can retrieve those top 3 (or whatever) types of results with a regular SQL query. But, since we have those powerful Window Functions, why not use them? My thoughts exactly! Besides, no one wants a spaghetti code mess of SQL to try and understand. Not to mention, Window functions are often better optimized for querying larger data sets. Continue reading and see example queries for more understanding…

[Keep reading for more SQL database and PHP/Python-centric content >>>]

3 MySQL Commands Developers should know.

If you are a developer working in a MySQL environment, this blog post is for you. I share 3 MySQL commands or statements that you should know. That is a bold statement, I know. Turns out, once you do know (of) these commands, you will use them all the time. They minimize guesswork which leads to better productivity in other facets of your programming and querying workflow. I use them myself almost daily and am sure you will too once you see how simple they are to use. So why should you know them? Continue reading and find out…

[Keep reading for more MySQL database and Python/PHP-centric content >>>]

Pivot query in MySQL – Learning by example.

While reading in a fantastic SQL book I frequent quite a bit, I discovered a type of query in one of the examples that I really should know. For a better learning experience, in order to solidly the concepts presented, I applied them to some data that I am familiar with. The topic: pivoting rows of data. Although I am aware of this data presentation, I have never studied a pivot query. ‘So why not learn it then’ I thought to myself. Are you interested in learning about a pivot query also? Continue reading and see an easy-to-comprehend example…

[Keep reading for more MySQL database and Python/PHP-centric content >>>]

Dynamic HTML drop-down with PHP and MySQL

After spending a great deal of time in my day job developing a web reporting dashboard/interface with PHP and MySQL, I feel that I have found my stride in back-end web development with PHP. Learning to develop web applications using the LAMP stack – or one of its derivatives (E.g., WordPress, CodeIgniter, Laravel, etc..) – is a huge focus for me right now. It’s no secret I am a MySQL fanatic – hence this blog – and have written about Python code along with the MySQL Shell a great deal here. However, as it normally goes for developers, the PHP/MySQL back-end web development has inspired me to, of course, start a side project. Go figure right! What developer doesn’t have a side project, or two? Be on notice that you will see more and more PHP/MySQL and LAMP-stack related posts in the future, in addition to the MySQL posts I regularly publish. In the meantime, I’ll share something super neat o (to me at least) I learned while working on my side project. I’m sure it is simple and standard for seasoned web developers, but sparks that exciting, exploratory learning feel for me. Continue reading to see more…

[Keep reading for more MySQL database and Python/PHP-centric content >>>]

Transaction in MySQL Shell – Python mode with examples

Although my day job has lately been filled primarily with MySQL and PHP development – which I absolutely enjoy – I still make spare time for MySQL and Python hacking; particularly in the MySQL Shell. For whatever reason, I am drawn back to this specific environment. SAVEPOINT, COMMIT, and START TRANSACTION are integral commands for working within a database transaction. MySQL Shell fully supports these commands. We can even execute them in Python mode! Continue reading to see them in action…

[Keep reading for more SQL database and Python-centric content >>>]