Session Prices

Feel free to negotiate depending on your situation.

Scheduling

Hit me up to work out a scheduled time and date.
[email protected]
213-995-7078 text or voice
Searching Using Dates

Let's get into searching by dates. Dates in MySQL are pretty powerful. You can specify ranges to include. For example, let's try to find anyone that started after the founders of the company:

mysql> select started, lastName, firstName, zip from names n left join addresses a on n.id=a.nameId where started > "2019-01-01" order by zip;
+---------------------+----------+-----------+-------+
| started             | lastName | firstName | zip   |
+---------------------+----------+-----------+-------+
| 2019-12-21 00:00:00 | Kella    | Shella    | 50000 |
| 2019-12-21 13:31:39 | Toga     | Sara      | 60000 |
+---------------------+----------+-----------+-------+
2 rows in set (0.00 sec)

Let's insert a few more records to make date searches more interesting:

mysql> insert into names (started, lastName, firstName) values 
("2019-05-01 00:00:00", "Flauntana", "Hannah"),
("2019-06-01 00:00:00", "Found", "Lost"),
("2019-07-01 00:00:00", "Donkey", "Man");
mysql> select * from names;
+----+---------------------+-----------+-----------+
| id | started             | lastName  | firstName |
+----+---------------------+-----------+-----------+
|  1 | 2019-01-01 00:00:00 | Smith     | Jim       |
|  2 | 2019-01-01 00:00:00 | Rocker    | Bob       |
|  3 | 2019-12-21 00:00:00 | Kella     | Shella    |
|  4 | 2019-12-21 13:31:39 | Toga      | Sara      |
|  5 | 2019-05-01 00:00:00 | Flauntana | Hannah    |
|  6 | 2019-06-01 00:00:00 | Found     | Lost      |
|  7 | 2019-07-01 00:00:00 | Donkey    | Man       |
+----+---------------------+-----------+-----------+
7 rows in set (0.00 sec)

Notice that even though we have started set to automatically add a timestamp, we can still manually fill that field in, if we want.

Let's add a few more addresses to the mix:

mysql> insert into addresses (nameId, street, city, state, zip) values 
(5, "4365 Destiny Failed Dr", "Known", "ID", "40000"),
(6, "345 Central Ave", "Inbetween", "CA", "90001"), 
(7, "6542 Ranch Dr", "Barham", "IN", "20000");
mysql> select * from addresses;
+----+--------+------------------------+-------------+-------+-------+
| id | nameId | street                 | city        | state | zip   |
+----+--------+------------------------+-------------+-------+-------+
|  1 |      1 | 1234 Main St           | Los Angeles | CA    | 10000 |
|  2 |      2 | 5678 North Dr          | Polka       | CA    | 90000 |
|  3 |      3 | 543 Asdf Wy            | Visia       | OR    | 50000 |
|  4 |      4 | 56743 Iso Dr           | Camden      | WA    | 60000 |
|  5 |      5 | 4365 Destiny Failed Dr | Known       | ID    | 40000 |
|  6 |      6 | 345 Central Ave        | Inbetween   | CA    | 90001 |
|  7 |      7 | 6542 Ranch Dr          | Barham      | IN    | 20000 |
+----+--------+------------------------+-------------+-------+-------+
7 rows in set (0.00 sec)

Okay, now let's do a full date range. Let's get anything after 2019-01-01 and anything before 2019-06-01:

mysql> select started, lastName, firstName, zip from names n left join addresses a on n.id=a.nameId where started > "2019-01-01" and started < "2019-06-01" order by zip;
+---------------------+-----------+-----------+-------+
| started             | lastName  | firstName | zip   |
+---------------------+-----------+-----------+-------+
| 2019-05-01 00:00:00 | Flauntana | Hannah    | 40000 |
+---------------------+-----------+-----------+-------+
1 row in set (0.00 sec)

We have a date in the database that lands on 2019-06-01, right? Let's include that:

mysql> select started, lastName, firstName, zip from names n left join addresses a on n.id=a.nameId where started > "2019-01-01" and started <= "2019-06-01" order by zip;
+---------------------+-----------+-----------+-------+
| started             | lastName  | firstName | zip   |
+---------------------+-----------+-----------+-------+
| 2019-05-01 00:00:00 | Flauntana | Hannah    | 40000 |
| 2019-06-01 00:00:00 | Found     | Lost      | 90001 |
+---------------------+-----------+-----------+-------+
2 rows in set (0.00 sec)

You'll notice that in the second started clause, I added a <= instead of just a <. This works exactly like an if statement, in that way.