- 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
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
312 Views
To calculate the average of values in a row in MySQL, use the following syntaxSELECT (yourTableName.yourColumnName1+yourTableName.yourColumnName2+yourTableName.yourColumnName3+, ..........N)/numberOfColumns AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table calculateAverageDemo -> ( -> x int, -> y int, -> z int -> ); Query OK, 0 rows affected (1.41 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into calculateAverageDemo values(10, 20, 30); Query OK, 1 row affected (0.78 sec) mysql> insert into calculateAverageDemo values(40, 50, 70); Query ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
800 Views
The contact() method is used to concatenate. However, lower() is used to change the case to lowercase. For our example, let us create a table.The query to create a table is as followsmysql> create table concatAndLowerDemo -> ( -> FirstValue varchar(10), -> SecondValue varchar(10), -> ThirdValue varchar(10), -> FourthValue varchar(10) -> ); Query OK, 0 rows affected (0.55 sec)Now you can insert some records in the table using insert command.The query is as followsmysql> insert into concatAndLowerDemo values('John', '12345', 'Java', 'MySQL'); Query OK, 1 row affected (0.21 sec) mysql> insert into concatAndLowerDemo values('Hi', '12345', ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
You can use COALESCE() along with aggregate function MAX() for this.The syntax is as followsSELECT COALESCE(MAX(`yourColumnName`), 0) FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table avoidNullDemo -> ( -> `rank` int -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into avoidNullDemo values(10); Query OK, 1 row affected (0.20 sec) mysql> insert into avoidNullDemo values(NULL); Query OK, 1 row affected (0.18 sec) mysql> insert into avoidNullDemo values(20); Query OK, 1 ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
364 Views
The return type of count is long. The Java statement is as followsrs.next(); long result= rs.getLong("anyAliasName");First, create a table with some records in our sample database test3. The query to create a table is as followsmysql> create table CountDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into CountDemo(Name) values('John'); Query OK, 1 row affected (0.21 sec) mysql> insert into CountDemo(Name) values('Carol'); Query OK, 1 row affected (0.16 sec) ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
209 Views
Let us first create a table in a database. The query to create a table is as followsmysql> create table customerDetails -> ( -> CustomerId int, -> CustomerName varchar(30) -> ); Query OK, 0 rows affected (0.56 sec)Now display all tables from the database in order to check the customerDetails table is present or not.The query is as followsmysql> show tables;The following is the output+------------------------------+ | Tables_in_test3 | +------------------------------+ | bestdateformatdemo | | customerdetails | | deletedemo ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
4K+ Views
To fix this error, you need to specify the -p option for password.The syntax is as followsmysql -uyourUserName -pLet us implement it.First, we need to open CMD using Windows+R shortcut keys. The snapshot is as followsType CMD and press OK button. You will get a command prompt.The snapshot is as followsNow reach the MySQL bin directory.The snapshot is as followsNow use the syntax discussed in the beginning.The command is as follows
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
You can use SET command for temporary variable assignment.The syntax is as followsSET @anyVariableName=(SELECT yourColumnName FROM yourTableName WHERE yourCondition);To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table tempVariableAssignment -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (0.59 sec)Now insert some records in the table using insert commandmysql> insert into tempVariableAssignment(Name, Age) values('John', 25); Query OK, 1 row affected (0.14 sec) mysql> insert into tempVariableAssignment(Name, Age) values('Carol', 26); Query ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
230 Views
At first, let us determine the current delimiter in MySQL using the following syntax\sThe above syntax will let you know about the current delimiter. Let us implement the above syntax.The query is as followsmysql> \sThe following is the outputC:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe Ver 8.0.12 for Win64 on x86_64 (MySQL Community Server - GPL) Connection id: 19 Current database: sample Current user: root@localhost SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256 Using delimiter: ; Server version: 8.0.12 MySQL Community Server - GPL Protocol version: 10 Connection: localhost via TCP/IP Insert id: 11 Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
987 Views
The AND has the highest priority than the OR operator in MySQL select query.Let us check how MySQL gives the highest priority to AND operator.The query is as followsmysql> select 0 AND 0 OR 1 as Result;The following is the output+--------+ | Result | +--------+ | 1 | +--------+ 1 row in set (0.00 sec)If you are considering the OR operator has the highest priority then MySQL will wrap up the above query like this.The query is as followsselect 0 AND (0 OR 1) as ResultFirst, solve the 0 OR 1, this will give result 1. After that ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
1K+ Views
You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place holder (?) to which we need to set date value.a Date object representing the date value to be passed. The constructor of java.sql.Date class accepts a variable of long type representing the number of milliseconds from the epoch (standard base time I.e. January 1, 1970, 00:00:00 GMT).ExampleAssume we have created ... Read More