Tag Archives: sql

MYSql copy tables

create table tablename_new like tablename; -> this will copy the structure… insert into tablename_new select * from tablename; -> this would copy all the data

Posted in MySQL | Tagged , | Comments Off

Find and replace in MYSQL

Updating Data in MYSql update [table_name] set [field_name] = replace([field_name],’[string_to_find]‘,’[string_to_replace]‘); For moving wordpress installs to repair the guid UPDATE wp_posts SET guid = replace( guid, ‘web/’, ” ) ;

Posted in MySQL, Wordpress | Tagged , , , , | Comments Off

WordPress Plugin Query

I am often cutting and pasting this in wordpress plugins $query = “SELECT id, post_title FROM ” . $wpdb->prefix . “posts WHERE post_type = ‘wpf_venue’ AND post_status=’publish’”; $venues = $wpdb->get_results ( $query, ARRAY_A );

Posted in plugins, Wordpress | Tagged , , , , | Comments Off