Archive for the ‘MySQL’ Category

View MySQL Processes

This item was filled under [ MySQL ]

To view MySQL connections, query:
> SHOW PROCESSLIST;
The above query won’t be useful for web applications that use a single user for DB. However, “mytop” (a console based tool) can be used for monitoring the threads and performance of MySQL.

To learn more about mytop, click here.

Continue reading...

MySQL: GROUP BY on DATETIME field

This item was filled under [ MySQL ]

Often webmasters want to sort out data on the basis of Dates when timestamp is stored as datetime in MySQL. To obtain the desired result, simply query:
SELECT DATE_FORMAT(MyDate, '%d %M %Y') AS Date, COUNT(*) AS numRows FROM Table1 GROUP BY Date;

Continue reading...

The basics of MySQL Views

This item was filled under [ MySQL ]

Before diving into any technicalities, I would like to share a little about “Views”. What is a VIEW, what is the benefit of it?
A view is a virtual or logical table composed of the result set of a query. Unlike ordinary tables (base tables) in a relational database, a view is not part of the [...]

Continue reading...

MySQL: Deleting/Identifying duplicate records

This item was filled under [ MySQL ]

A simple way out to delete duplicate entries is to copy DISTINCT values to a temporary table. I tried it over 2 field table with 0.1 million rows and it worked perfectly for me.
CREATE TABLE NewTable …;

INSERT INTO NewTable(field1)
SELECT DISTINCT field1 FROM MyTable;

DROP TABLE MyTable;
Alternately, if you’re populating your database and would like to avoid [...]

Continue reading...

PAMP: Personal Apache MySQL PHP

This item was filled under [ MySQL, PHP ]

[..] The new acronym is for Personal Apache MySQL and PHP (PAMP) is an experimental project by Nokia to provide an open source personal web server for their S60-based mobile phones.
You can install PAMP using PCSuite or simply by copying files to your memory card.
The downloaded package itself include Python, PythonScript Shell, Pips, Open SSL [...]

Continue reading...

Tagged with: [ , ]

Setting next AUTOINCREMENT value

This item was filled under [ MySQL ]

By default, MySQL starts auto-incrementing from value 1. To start with value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:
mysql> ALTER TABLE [tablename] AUTO_INCREMENT = [number];
An alternate way of doing this is, simply insert a row in your Table and enter the next auto-increment value.
Enjoy! =)

Continue reading...