- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why does MySQL refuse pipe ('|') character in string on INSERT INTO?
To insert pipe(|) character in string on INSERT INTO, let us first see an example and create a table. The query to create a table is as follows
mysql> create table PipeInsertDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserPassword varchar(100) -> ); Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into PipeInsertDemo(UserPassword) values('John123|'); Query OK, 1 row affected (0.15 sec) mysql> insert into PipeInsertDemo(UserPassword) values('|123456CarolTaylor'); Query OK, 1 row affected (0.13 sec) mysql> insert into PipeInsertDemo(UserPassword) values('Adam|345Smith'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from PipeInsertDemo;
The following is the output
+--------+--------------------+ | UserId | UserPassword | +--------+--------------------+ | 1 | John123| | | 2 | |123456CarolTaylor | | 4 | Adam|345Smith | +--------+--------------------+ 3 rows in set (0.00 sec)
Advertisements