Posts

Showing posts from November, 2013

postgreSQL usage

Basic usage comparing to mysql mysql:  SHOW TABLES postgresql:  \d postgresql:  SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'; mysql:  SHOW DATABASES postgresql:  \l postgresql:  SELECT datname FROM pg_database; mysql:  SHOW COLUMNS postgresql:  \d   table postgresql:  SELECT column_name FROM information_schema.columns WHERE table_name =' table '; mysql:  DESCRIBE TABLE postgresql:  \d+   table postgresql:  SELECT column_name FROM information_schema.columns WHERE table_name =' table '; Join usage Join 2 tables: SELECT      A.pka,      A.c1,      B.pkb,      B.c2 FROM      A INNER JOIN B ON A .pka = B.fka; Join 3 tables : t1 and t3 merger to t2: SELECT t1.column1, t2.column2, t3.column3 FROM   table1name t1 INNER JOIN table2name t2 ON t1.id = t2.id INNER JOIN  table2name t2 ON t3.id = t2.id; t1 merge to t2, then merger to t3: SELECT t1.column1, t2.column2

mysql connection related to EUR € symbol using PHP

"€" can not be recognized by  ISO-8859-1 standard as it is encoded by  UTF-8. By default, mysql connection using  ISO-8859-1 based connection, and will turn  "€"  as " â " using mysql query.    In order to get a correct "€", then mysql connection should be like this: $conn = mysql_connect($host.':'.$port, $username, $password); mysql_set_charset("utf8"); $query = "select ..."; $db= mysql_select_db($database, $conn); $result = mysql_query($query);