If you want to add a counter to a web page or a website then use the below simple PHP Counter Script using MySql. It is very easy to implement it and it counts whenever a page is being refreshed and the script won’t reduce page speed, unlike page counter scripts. PHP Visitor Counter Script […]
Mysql
MySQL Offset Limit Data Selections
MySQL provides a LIMIT clause that is used to specify the number of records to return. The LIMIT clause makes it easy to code multi page results or pagination with SQL, and is very useful on large tables. Assume we wish to select all records from 1 – 30 (inclusive) from a table called “Orders”. […]
10 Mistakes Which PHP MySQL Developers Make
1. Using MyISAM rather than InnoDB MySQL has a number of database engines, but you’re most likely to encounter MyISAM and InnoDB. MyISAM is used by default. However, unless you’re creating a very simple or experimental database, it’s almost certainly the wrong choice! MyISAM doesn’t support foreign key constraints or transactions, which are essential for […]
How to Get the Current Timezone of Mysql Database
By running below query you can able to get the Current Timezone of the database server. select timediff(now(),convert_tz(now(),@@session.time_zone,’+00:00′));
How to Add Column to Mysql Table and Auto Increment with Primary Key
Check below on How to Add a Column to Mysql Table with Auto Increment and Primary Key You can achieve it by doing Alter Command: Add Column to Mysql To Modify Column and add Auto Increment with Primary Key Query: ALTER TABLE test MODIFY COLUMN ID INT(10) PRIMARY KEY auto_increment; ALTER TABLE users ADD id […]
How to Get Size of a Database in Mysql
To Get Data Base Size in MB and Free Space in MBSELECT table_schema “dbName”, sum( data_length + index_length ) / 1024 / 1024 “Data Base Size in MB”, sum( data_free )/ 1024 / 1024 “Free Space in MB”FROM information_schema.TABLESGROUP BY table_schema ; To Get Size in GB: SELECT sum(round(((data_length + index_length) / 1024 […]
How to find duplicate rows in Sql or Mysql
You can find duplicate rows in the mysql table, just use below select query, to find duplicate rows in Oracle, Sql, Mysql, DB2. SELECT columnName, COUNT(*) as countFROM selectedTableGROUP BY columnNameHAVING COUNT(*) > 1; You came from below query:how to find duplicate rows in sql server 2008how to find duplicate rows in sql and deletehow […]
alter table and make id as auto increment
ALTER TABLE internal MODIFY COLUMN id INT(32) NOT NULL auto_increment PRIMARY KEY;
Export to Excel Using PHP and Mysql
Below simple program will export mysql data values to excel sheet without using any PHP libraries. Export to Excel Using PHP and Mysql Note: IF you get errors or in excel all the data is in one column, then instead t tab space use, comma ‘,’.
Best way to loop through a PHP mysql Resultset
If you want to loop throuh the mysql result set twice then use below way. $result = mysql_query(“SELECT * FROM my_table”);while($row = mysql_fetch_assoc($result)) {// inside the loop} The problem is, if you want to loop through the same result set again, you will get an error because the internal pointer is currently at the end […]