Created
April 25, 2014 14:29
-
-
Save thor48/11291532 to your computer and use it in GitHub Desktop.
SQL find and replace Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE `wp_posts` | |
SET `post_content` = replace(post_content, '/testing/', '/') | |
WHERE `post_content` LIKE '%/testing/%' | |
In this example we find any text named '/testing/' and replace it with '/' within table wp_posts in column post_content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MySQL Run SQL Queries From A Shell Prompt / Command Line
mysql -u user -p -e 'SQL Query' database
Where,
-u : Specify mysql database user name
-p : Prompt for password
-e : Execute sql query
database : Specify database name
To list all database, enter:
$ mysql -u vivek -p -e 'show databases;'
To list count all rows, enter:
$ mysql -u vivek -p -e 'SELECT COUNT(*) FROM quotes' cbzquotes
Sample output: