- 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 6702 Articles for Database
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
120 Views
You can use CHAR_LENGTH() along with the WHERE clause. Let us first create a table −mysql> create table DemoTable -> ( -> FullName varchar(50) -> ); Query OK, 0 rows affected (1.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris Brown'); Query OK, 1 row affected (0.40 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 row affected (0.91 sec) mysql> insert into DemoTable values('Robert Miller'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.89 sec)Display all records from the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
To split a column, you need to use SUBSTRING_INDEX() in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(40) -> ); Query OK, 0 rows affected (1.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John_Smith'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable values('Carol_Taylor'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values('David_Miller'); Query OK, 1 row affected (0.54 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
141 Views
Let us first create a table −mysql> create table DemoTable -> ( -> JoiningDate datetime -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2015-01-21'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2017-04-02'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('2018-12-31'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+ | JoiningDate | +---------------------+ | 2015-01-21 00:00:00 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
47 Views
Yes, it is possible using the # symbol. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY , # Creating a sequence Number -> FirstName varchar(20), # Creating a column to store name -> Age int # creating a column to store an age -> ); Query OK, 0 rows affected (1.43 sec)Above, we have set comments using the # symbol. Insert some records in the table using insert command. We will set comments in insert statement as well using the same # symbol ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
738 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Marks1 int, -> Marks2 int, -> Marks3 int -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Marks1, Marks2, Marks3) values(45, 67, 34); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable(Marks1, Marks2, Marks3) values(89, 87, 56); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Marks1, Marks2, Marks3) values(87, 56, 54); Query OK, 1 row affected (0.31 sec)Display ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
For this, you can use GROUP BY along with the ORDER BY clause. Let us first create a table &mins;mysql> create table DemoTable -> ( -> URL varchar(40), -> DomainName varchar(20), -> SearchTimes int -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('www.gmail.com', 'gmail.com', 4); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('www.google.com', 'google.com', 3); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('www.gmail.com', 'gmail.com', 9); Query OK, 1 row affected (0.15 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
108 Views
Use SELECT ENGINE to display the storage engine name. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int, -> CountryName varchar(20) -> ); Query OK, 0 rows affected (0.63 sec)Here is the Java code to get the storage engine using JDBC −Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class GetTheStorageEngine { public static void main(String[] args) { String hostURL = "jdbc:mysql://localhost:3306/web?useSSL=false"; Connection con = null; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
261 Views
To get the last second of a date in MySQL, use the INTERVAL command. Let us first create a table −mysql> create table DemoTable -> ( -> JoiningDatetime datetime, -> DueDatetime datetime -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(JoiningDatetime) values('2019-11-03 12:34:54'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(JoiningDatetime) values('2019-10-04 12:34:54'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+-------------+ | JoiningDatetime ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
124 Views
You can use ORDER BY TRIM(). Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (1.09 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MongoDB is a no SQL database'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('The MySQL is a relational database'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('The Java language is good'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Python is good language'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
324 Views
To fix, you need to put MySQL connector to the Java classpath. Import the jar file of the connector to the project folder for the IDE you are using.Here is the snapshot to place classpath −Let us now see the code for connectivity in Java with MySQL −This will produce the following output −