- Trending Categories
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
Found 4378 Articles for MySQL
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
335 Views
No, you can easily add a column before another column using ALTER.Note − To add a column at a specific position within a table row, use FIRST or AFTER col_name Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20), -> CountryName varchar(100) -> ); Query OK, 0 rows affected (0.67 sec)Let us check all the column names from the table −mysql> show columns from DemoTable;OutputThis will produce the following output −+-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
686 Views
To set a variable, use MySQL SET. For adding integers from a variable, use UPDATE and SET as in the below syntax −set @anyVariableName:=yourValue; update yourTableName set yourColumnName=yourColumnName+ @yourVariableName;Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.15 sec) mysql> ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
454 Views
Use the BINARY keyword to force REGEXP to match the string as a binary string. We will see the difference here.Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command. We have names here with different cases −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('JOHN'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('john'); Query OK, 1 row affected (0.16 sec) mysql> insert ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
278 Views
Use the LOCATE() and SUBSTRING() method for this in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Introduction To Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Introduction - To MySQL'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+-------------------------+ | Title ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
Use the CONV() method to convert hex string to number −select CONV(yourColumnName, 16, 10) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> HexString varchar(100) -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('A'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values('F'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('B'); Query OK, 1 row affected (0.55 sec) mysql> insert into DemoTable values('ABC'); Query OK, 1 row affected (0.11 sec)Display ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
175 Views
Use the SUBSTR() method to extract the middle part of column values surrounded with hyphens, for example, “11-84848-11”.Let us first create a table −mysql> create table DemoTable -> ( -> Number varchar(100), -> Number1 varchar(100) -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Number) values('11-84848-11'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Number) values('22-99999-22'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+-------------+---------+ | Number ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
3K+ Views
To set a string with hyphen and numbers, you need to use single quotes. For example, 'Customer-1234-899', 'Customer-9383-901', etc.Let us first create a table −mysql> create table DemoTable -> ( -> CustomerId varchar(100) -> ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Customer-1234-899'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Customer-8373-900'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Customer-9383-901'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTableOutputThis ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
463 Views
For this, use UPDATE and REPLACE() in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentCountryName varchar(100) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName, StudentCountryName) values('John', 'US'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql select *from DemoTable;OutputThis will produce the following output −+-----------+-------------+--------------------+ | StudentId | StudentName | StudentCountryName | +-----------+-------------+--------------------+ | ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
917 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+----+ | Id | +----+ | 1 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('STU#123'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('STU#567'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('STU#98494'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+-----------+ | StudentId | +-----------+ | STU#123 | | STU#567 ... Read More