SQL

Insert using select

INSERT INTO theme_name (theme_id, lang, value) SELECT id, 'en', name_en FROM theme;

Note: it's possible to add conditions.

Select random rows

mySQL

ORDER BY rand()
LIMIT 1

PostgreSQL

ORDER BY random()
LIMIT 1

Ref: http://www.carlj.ca/2007/12/16/selecting-random-records-with-sql/

Search and replace text

UPDATE a_table SET a_column = REPLACE(a_column, 'oldtext', 'newtext');

Feedback

1.Second column should be allowed string value.
2.The no.of columns ie selecting from this table should be equal to no.of columns inserted to this table and particular column datatype should be same.
Bharathi
Nov 25, 2010
#1