When storing big text contents in a database, it is better to store after compressing the data. The following is an example storing HTML contents in a database cache. We first create a table mapping URLs to HTML contents. The…
When storing big text contents in a database, it is better to store after compressing the data. The following is an example storing HTML contents in a database cache. We first create a table mapping URLs to HTML contents. The…
Here we show an example of updating two table at the same time using joins. Suppose we have two tables: lookup which holds information on a person, and activity which holds certain activities happening on a person. Imagine that lookup…
Selecting random records from a table is helpful when showing items with no preferences or testing different result sets. The following SQL defines a table holding images. Imagine that we wish to pick up 10 random rows from it. In…
The next query generates results as below. Suppose we want to add a column with serial numbers, just as below. In MySQL, this can be done by defining a variable in the query: Reference: MySQL User Defined Variables