MySQL: Datetime Versus Timestamp Data Types
The temporal data types in MySQL can be confusing. Hopefully, this example and discussion will help to explain the differences in the timestamp and datetime data types.
Category MySQL
How to Create a Basic MySQL Table
Creating tables in databases is an important first step for storing data. The CREATE TABLE statement is rich and sometimes confusing. This tech-recipe with an example describes the basics of creating a table in MySQL.
Category MySQL
MySQL: How to get row number order
These directions walk through how one can displaying the row number order/rank for result set obtained from executing a sql query. An example with walkthrough explanation is provided.
MySQL: Increment an exisitng value
This slick MySQL syntax allows you to increment or decrement an existing number in a table without first having to read the value. This is a nice way to increment an access counter.
Category MySQL
MySQL: Use CONCAT to include text in SELECT results
The CONCAT function in MySQL allows SELECT statements to act like printf commands by mingling text and query results together.
Category MySQL
Copy an existing MySQL table to a new table
This is a great set of two commands that allow the creation and population of a new table with the structure and data of an existing table. This provides a quick means of making a point-in-time copy of a table and is a safe, easy way to make a quick copy of a table for […]
Category MySQL
Rename or change name of MySQL table
If you change your mind and want to rename an existing MySQL table, with or without data in it, it is no problem. One simple command will change the table’s name.
Category MySQL
Ignore duplicate entries in MySQL select using DISTINCT keyword
Sometimes every occurance of a value which may be duplicated multiple times in a result set is not needed. For example, if making a pulldown menu list of options, each option should be seen only once. The DISTINCT keyword in a select statement eliminates duplication in the result set.
Category MySQL
Save MySQL query results into a text or CSV file
MySQL provides an easy mechanism for writing the results of a select statement into a text file on the server. Using extended options of the INTO OUTFILE nomenclature, it is possible to create a comma separated value (CSV) which can be imported into a spreadsheet application such as OpenOffice or Excel or any other applciation […]
Category MySQL
Get MySQL date in RFC-822 format for RSS feeds
To get the PubDate element of an RSS feed to validate, it needs to be in RFC-822 format. MySQL has flexible ways of working with dates and times which make this a simple task.
Category MySQL
Solve: Can’t connect to local MySQL server through socket /tmp/mysql.sock
A frequent error message received when using the mysql command line utility is: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ While this error message can be frustrating, the solution is simple.
Category MySQL
Use regular expressions in MySQL SELECT statements
A very cool and powerful capability in MySQL and other databases is the ability to incorporate regular expression syntax when selecting data. The regular expresion support in MySQL is extensive. This recipe reviews regular expression use in MySQL and lists the supported regular expression metacharacters.
Category MySQL