- 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
Kumar Varma has Published 110 Articles
Kumar Varma
389 Views
For this, you can use GROUP BY and use COUNT to get only non-duplicate values. Following is the syntax −select yourColumnName from yourTableName group by yourColumnName having count(*)=1;Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More
Kumar Varma
123 Views
Let us first create a table. We have used AUTO_INCREMENT while creating the table to set auto increment for StudentId −mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT, -> StudentFirstName varchar(100), -> StudentLastName varchar(100), -> StudentAge int, -> StudentCountryName varchar(100), ... Read More
Kumar Varma
74 Views
To count where more than three column values are true, you can use WHERE clause. Let us first create a table −mysql> create table DemoTable -> ( -> isMarried boolean, -> isActive boolean, -> isMember boolean, -> isOn boolean -> ); Query OK, 0 ... Read More
Kumar Varma
106 Views
For this, you can use LEAST(). Following is the syntax −select least(yourColumnName, yourMaxValue) from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> ... Read More
Kumar Varma
274 Views
To get age from DOB, you can use the TIMESTAMPDIFF() function. Following is the syntax −select TIMESTAMPDIFF(YEAR, yourColumnName, CURRENT_DATE) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> DateOfBirth datetime -> ... Read More
Kumar Varma
145 Views
For this, use ORDER BY clause. The current date is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 21:08:16 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table ... Read More
Kumar Varma
163 Views
To get the current size of a table, use the following that will display details about a table including the size −show table status like ‘yourTableName’\GLet us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName ... Read More
Kumar Varma
2K+ Views
To convert time to seconds, use the TIME_TO_SEC() method. Let us first create a table −mysql> create table DemoTable -> ( -> ArrivalTime time -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('04:10:00'); Query ... Read More
Kumar Varma
116 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.17 sec) mysql> insert ... Read More
Kumar Varma
172 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('Carol'); Query ... Read More