mysql: import csv data

by prettyscripts on 2011-12-16 10:47:00 • Leave a comment »

sql

there are a few ways to to it. here's a solution using load data. load data local infile '/path/to/csvfile' fields terminated by ',' enclosed by '"' lines terminated by '\n' [ignore 1 lines] [(column_1, @dummy, column_2,...)] notes line 5: t… more »

Tags: csv, data, import, mysql, sql

wordpress: change url

by prettyscripts on 2011-09-12 10:44:00 • 1 comment »

phpsqlwordpress

when deploying a site (and database) from development to production, when going to the production the site goes back to development. that's because in wordpress, site url is defined and saved in database by default. according to the official document,… more »

Tags: mysql, php, sql, wordpress, wp

sql: order by ascending order with null at the end

by prettyscripts on 2011-07-25 11:38:00 • 1 comment »

sql

when using 'order by' clause to sort columns in ascending order, rows with null value comes first. what if the requirement is to sort in ascending order but rows with null values comes last? use case. select * from table order by case when column… more »

Tags: mysql, null, order, sort, sql

b2evo: moving post to another blog

by prettyscripts on 2010-02-17 14:26:21 • 1 comment »

b2evolution

this refers to moving a post or page from one blog to another, within the same b2evolution installation. i can't seem to find any interface in the back office to do this. the database needs to be updated directly, but it's not as easy as updating the b… more »

Tags: b2evo, move, mysql

mysql: convert number to string

by prettyscripts on 2009-05-29 10:51:17 • Leave a comment »

miscsql

to copy value from a column in table a to a column in table b, the syntax is straight forward:insert into new_table (new_column)select old_column from old_table but when new_column is varchar and old_column is integer, you will get an error.… more »

Tags: convert, mysql, number, string