- 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)
2K+ Views
For this, you can use PreparedStatement from Java. Let us first create a table wherein one of the columns is ArrivalDate with DATE type −mysql> create table DemoTable( PassengerId int, PassengerName varchar(40), ArrivalDate date ); Query OK, 0 rows affected (0.82 sec)The JAVA code is as follows to insert date −import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class InsertDateFromJava { public static void main(String[] args) { Connection con = null; PreparedStatement ps = null; try { java.util.Date javaDate = new java.util.Date(); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
222 Views
The incremented value can be set in a user-defined variable as shown below. Here, “yourValue” is the incremented value. After that, use MySQL UPDATE to update the column and increment timestamp values −set @anyVariableName :=yourValue; update yourTableName set yourColumnName=yourColumnName+interval (@yourVariableName) second;Let us first create a table −mysql> create table DemoTable ( DueDatetime timestamp ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-01-31 12 :30 :40'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('2019-09-06 10 :00 :00'); Query OK, 1 row affected (0.73 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
97 Views
To count items, use COUNT() along with DISTINCT. Here, DISTINCT is used to return distinct values. Let us now see an example and create a table −mysql> create table DemoTable ( CustomerId int, CustomerName varchar(20), ProductName varchar(40) ); Query OK, 0 rows affected (1.02 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(101, 'Chris', 'Product-1'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(102, 'David', 'Product-2'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(101, 'Chris', 'Product-1'); Query OK, 1 row affected (0.30 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
67 Views
To ORDER BY grouped fields, use ORDER BY CASE along with IN(). CASE evaluates different conditions whereas ORDER BY sort values in ascending or descending order. The MySQL IN() is used to find a match.Let us first create a table −mysql> create table DemoTable ( Value varchar(40) ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('100&101'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Sam'); Query OK, 1 row affected (0.09 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
269 Views
Use SELECT 1 for this as in the below syntax −select 1 from yourTableName where yourColumnName=yourValue;If the above returns 1, that means value exists in the MySQL database. Let us first see an example and create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(40), StudentAge int ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName, StudentAge) values('Chris', 21); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(StudentName, StudentAge) values('David', 20); Query OK, 1 row affected (0.16 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
146 Views
Let us first create a table −mysql> create table DemoTable ( FirstName varchar(20) ); Query OK, 0 rows affected (1.15 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-----------+ | FirstName | +-----------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
371 Views
Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(40), StudentMathMarks int, StudentMySQLMarks int, status ENUM('ACTIVE', 'INACTIVE') ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName, StudentMathMarks, StudentMySQLMarks, status) values('Chris', 45, 67, 'active'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(StudentName, StudentMathMarks, StudentMySQLMarks, status) values('Bob', 89, 78, 'inactive'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(StudentName, StudentMathMarks, StudentMySQLMarks, status) values('David', 56, 68, 'active'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
The only difference between BIGINT and BIGINT(20) is for displaying width. The 20 can be used for displaying width.Let us see an example and create a table. Here, we have set BIGINT(20) −mysql> create table DemoTable ( Number bigint(20) zerofill ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(12); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(123); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1234); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
157 Views
Let us first create a table −mysql> create table DemoTable ( Name varchar(40) ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Sam'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Mike'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Ethan'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Johnson'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Bob'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
77 Views
For this, use LEFT() method. For manipulation, we have used the LOCATE() and the REVERSE() method.Let us first create a table −mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('$/This$is[MySQL]$/MySQL[FirstClass]$MySQL[SecondClass]'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('$/This$is[Java]$/Java[FirstClass]$Java[SecondClass]'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------------------------------------------------------+ | Title ... Read More