Ques 81. How To Escape Special Characters in SQL statements?
There are a number of special characters that needs to be escaped (protected), if you want to include them in a character string. Here are some basic character escaping rules:
► The escape character () needs to be escaped as ().
► The single quote (') needs to be escaped as (') or ('') in single-quote quoted strings.
► The double quote (") needs to be escaped as (") or ("") in double-quote quoted strings.
► The wild card character for a single character (_) needs to be escaped as (_).
► The wild card character for multiple characters (%) needs to be escaped as (%).
► The tab character needs to be escaped as (t).
► The new line character needs to be escaped as (n).
► The carriage return character needs to be escaped as (r).
Here are some examples of how to include special characters:
SELECT 'It''s Sunday!' FROM DUAL;
It's Sunday!
SELECT 'Allo, C'est moi.' FROM DUAL;
Allo, C'est moi.
SELECT 'MontTuetWedtThutFri' FROM DUAL;
Mon Tue Wed Thu Fri
Is it helpful?
Add CommentView Comments
Ques 82. How To See the CREATE TABLE Statement of an Existing Table?
SHOW CREATE TABLE test;
Is it helpful?
Add CommentView Comments
Ques 83. How To Concatenate Two Character Strings?
If you want concatenate multiple character strings into one, you need to use the CONCAT() function. Here are some good examples:
SELECT CONCAT('Welcome',' to') FROM DUAL;
Welcome to
SELECT CONCAT('wb','center','.com') FROM DUAL;
WithoutBook.com
Is it helpful?
Add CommentView Comments
Ques 84. How To Create a New Table by Selecting Rows from Another Table in MySQL?
Let's say you have a table with many data rows, now you want to create a backup copy of this table of all rows or a subset of them, you can use the "CREATE TABLE ... SELECT" statement. The tutorial script below gives you a good example:
mysql> INSERT INTO tip VALUES (1, 'Learn MySQL',
'Visit www.GlobalGuideLine.com','2006-07-01');
Query OK, 1 row affected (0.62 sec)