MySQL

Posts related to MySQL

What does int(11) means in MySQL?

A very common misconception about what int(11) means in MySQL is that the column can store maximum integer value with 11 digits in length. However, this is not true. int(11) does not determines the maximum value that the column can store in it. 11 is the display width of the integer column, unlike the characters …

What does int(11) means in MySQL? Read More »

How to get size of BLOB in MySQL

Recently I wanted to get the size of the data stored in the BLOB field of a MySQL table. BLOB is a field which can be used to store variable amount of data. There is a simple MySQL String function, to find the size of BLOB data, OCTET_LENGTH. This function returns the length of BLOB …

How to get size of BLOB in MySQL Read More »

MySQL ordering results by specific field values

In MySQL we can sort the results in ascending or descending order very easily by using the ORDER BY clause. However, there are times when you want to sort the results in a specific order which cannot be done using the ASC or DSC. FIELD() of MySQL ORDER BY clause can be used to sort …

MySQL ordering results by specific field values Read More »

Sample MySQL table

For my MySQL posts here is a sample MySQL table that I would be using for my examples. I would refer my posts back to this for table structure and sample data. Table structure: +———+————-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +———+————-+——+—–+———+——-+ | name | varchar(20) | YES …

Sample MySQL table Read More »

How to Find and Replace Data in MySQL

Recently, while migrating my blog, I had to find all the occurrences of my old URL and replace it with my URL. One way of doing this was to get a database dump, open it in a text editor and the do a find replace and the import it back. This is a 4 step …

How to Find and Replace Data in MySQL Read More »