Monday, July 9, 2012

how to use the switch statement in php

switch statement can be extremely useful in complex situations.

switch($variable)
{
case "a":
        // run the code if $variable =  a .
break;
case "b":
        // run the code if $variable = b .
break;
case "c":
        // run the code if $variable = c .
break;
default:
        // run the code if $variable is not equal to either a,b or c
}


Monday, February 27, 2012

check existing mysql triggers

SELECT * FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA= 'database_name';

OR

SHOW TRIGGERS;

create mysql triggers


table names
testing.name
testing_T.fullname

CREATE TRIGGER addnm AFTER INSERT ON testing
FOR EACH ROW BEGIN
INSERT INTO testing_T SET fullname =  NEW.name;
END;

delimiter |

Monday, February 6, 2012

find duplicate rows in a mysql table

example field = reference
example table = outstandings


" select reference from outstandings group by reference having count(*)>=2 "