During many decision-making phases in programming code (conditional logic), there are times execution depends on several different factors. Multiple conditional tests are powerful and constraining, oftentimes requiring more than one test to be passed in order for program flow to proceed.
For MySQL (and standard SQL in general) the CASE
expression is used for IF
/THEN
/ELSE
conditional logic. The post, MySQL Simple CASE Expression – with examples, covered Simple CASE
queries which are essentially equality tests. MySQL Simple CASE
is but one variant of 2, with the other being a MySQL Searched CASE
Expression. A MySQL Searched CASE
Expression can have multiple conditional tests in each WHEN
clause. These conditional tests can be AND
/OR
comparisons, BETWEEN
value range tests, subqueries, IN()
operators, and more. Continue reading to see examples of the MySQL Searched CASE
Expression…
Writing
MySQL Simple CASE Expression – with examples
Programming logic is foundational in any application or piece of software. Without it, software wouldn’t really do much of anything. Everything happens off of choice. In the end, some truthy or falsy value is what makes stuff work. For IF
/THEN
/ELSE
logic in standard SQL, there is the CASE
expression. There are 2 variations of the CASE
Expression: Simple and Searched. In this post, I cover the Simple MySQL CASE
expression with example queries…
MySQL Column Aliases using the AS keyword
Be it running reports or displaying data in some other visualization, SQL SELECT
column expressions should be meaningful and understandable. To provide those valuable query results, SQL Developers, use a multitude of available functions, adjacent columns, or other means not readily apparent to end-users. All that being said, the column names often suffer the most as far as readability is concerned, taking on long function call names or other combined expressions. But, as luck would be on our side, there is an easy fix and that is aliasing columns using the AS
keyword. Although AS
is optional – in this particular context – I err on the side of readability and use it when aliasing SELECT
column expressions.
Comparing SQLite and Realm: What Is the Best Database for Android
Any Android application requires dedicated storage space. And various databases help developers in this. However, a lot depends on the choice of the database, and the wrong choice can bury the perfect application. When creating an app for Android, there are two most popular databases SQLite and Realm. Many developers cannot choose between them for a long time since each has its own pros and cons. Today we will compare these two databases and find out what is better for developing Android applications. Without further ado, let’s get started.
(more…)How to Use SQL in SEO
If you talk to any search engine optimization specialist, they’ll surely tell you how many tools are used throughout their workday – from keyword research and backlinking to crawling and metric analysis tools. SEO is a world of its own with countless facets of information that need tweaking and examination constantly. It can quickly become overwhelming if you don’t have the right tools at your disposal. Or if you simply don’t understand how to make your job easier with SQL.
(more…)