
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- Insert a String into another String in Java
- How do I insert a special character such as ' (single quote) into MySQL?
- Why does a goldsmith blow air into the kerosene lamp flame with a blow-pipe?
- Insert a character at nth position in string in JavaScript
- Get part of a string based on a character in MySQL?
- Insert JSON into a MySQL table?
- Split a string and insert it as individual values into a MySQL table?
- Insert NULL value into INT column in MySQL?
- Insert datetime into another datetime field in MySQL?
- Java Program to Insert a string into another string
- Golang program to insert a string into another string
- Python Program to Insert a string into another string
- Swift Program to Insert a string into another string
- MySQL INSERT INTO SELECT into a table with AUTO_INCREMENT
- Why it shows 0 instead of empty string whenever I insert an empty string into a MySQL column which is declared as NOT NULL?

Advertisements