Friday, August 31, 2012

INSERT to a table by SELECT


INSERT INTO Target_Table (col1, col2, col3)
SELECT col1,col2,col3
FROM Source_Table

http://dev.mysql.com/doc/refman/5.5/en/insert.html

Thursday, August 30, 2012

Get values from 2 queries


select (a.count1/b.count2) as result from
(SELECT count(*) as count1 FROM table1) as a,
(SELECT count(*) as count2 FROM table2) as b

Tuesday, August 21, 2012

Date comparison


if(strtotime("now") < strtotime('2012-08-21 9:54')){
    echo  "something... ";
}