MySql find all tables with specific column/field name

December 8, 2014

How to look up in the entire DB and list out all tables which have specific column name or field name? Example belows looks for field `currency` from all database: To add specific database to the query, use:

PHP MySql query for random record from database table

September 5, 2014

The simplest way of selecting random rows from the MySQL database is to use “ORDER BY RAND()” clause in the query. Example:

Ubuntu 10.04.4 upgrade php 5.3.2 to 5.3.6

August 22, 2014

For anyone who wants to upgrade Ubuntu 10.04 LTS to PHP 5.3.10, this is how I have done it. Note sudo apt-add-repository ppa:brianmercer/php5 doesn’t work anymore. Suspect has been taken down. sudo apt-add-repository ppa:brianmercer/php5 will not work anymore However the steps below do work!! sudo add-apt-repository ppa:bjori/php5 sudo apt-get update sudo aptitude show php5 Package: […]

PHP Prepare IN statement from array

April 14, 2014

Some of us may not know that when preparing mysql IN statement, the string inside the IN() need to be single quoted and separated by comma. Example: Unless it is a number. Otherwise double quote or no quoting the string will give you error. Example: WHERE categories IN (“red”, “blue”, “green”) To prepare IN statement […]

MYSQL MODIFY column to NULL

March 17, 2014

Some newer version of phpmyadmin by default when create field name not allow NULL. after added the field, we can use MODIFY command to change it default null. Mysql MODIFY command example:

MySql query ORDER BY two columns

January 24, 2014

You can order by multiple columns in mysql. The first order take first preference and then second one get next preference in mysql. Example: Statement lik: will sort both columns descending. If specified each column ASC or DESC, first order will take first preference and then second one get next preference in mysql

MySQL modify field value allow NULL

December 19, 2013

Columns are nullable by default. As long as the column is not declared UNIQUE or NOT NULL . However, things may change during development or to prevent insert error. Thus, run this comman, example: