
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
2K+ Views
For this, use IF() in MySQL. The syntax is as follows −select IF(yourColumnName1=0, yourColumnName2, yourColumnName1) as anyAliasName from yourTableName;Let us create a table −mysql> create table demo30 −> ( −> id int not null auto_increment primary key, −> value int, −> original_value int −> ) −> ; Query OK, 0 ... Read More

AmitDiwan
1K+ Views
Following is the syntax to order by multiple columns −select *from yourTableName order by yourColumnName1 DESC, yourColumnName2, yourColumnName3;Let us create a table −mysql> create table demo29 −> ( −> value1 int, −> value2 int −> ); Query OK, 0 rows affected (1.67 sec)Insert some records into the table with the ... Read More

AmitDiwan
124 Views
For this, you need to use the WHERE clause. Following is the syntax −select *from yourTableName where yourColumnName > yourValue;Let us create a table −mysql> create table demo27 −> ( −> id int not null auto_increment primary key, −> value int −> ); Query OK, 0 rows affected (3.14 sec)Insert ... Read More

AmitDiwan
483 Views
For this, you can use REGEXP_REPLACE(). Let’s say our string is −This is my first MySQL query. This is the first tutorial. I am learning for the first time.We need to replace only the 1st occurrence of a specific word, let’s say “first”. The output should be −This is my ... Read More

AmitDiwan
148 Views
To configure a DataSource in Springboot, you can define DataSource into application.properties.The application.properties is as follows for Springboot −spring.datasource.username=yourUserName spring.datasource.password=yourPassword spring.datasource.url=yourDatabaseUrl spring.datasource.driver-class-name=yourDriverClassNameThe project structure is as follows −ExampleTo understand the above concept, let us create a controller class with spring boot. The Java code is as follows −package com.demo.controller; import ... Read More

AmitDiwan
2K+ Views
To set default value, use the DEFAULT constraint as in the below syntax −alter table yourTableName modify column yourColumnName JSON NOT NULL DEFAULT ( JSON_OBJECT() );Let us create a table −mysql> create table demo24 −> ( −> employee_information text −> ) −> ; Query OK, 0 rows affected (1.43 sec)Here ... Read More

AmitDiwan
280 Views
For this, use aggregate function COUNT(*) along with subquery. GROUP BY is also used.Let us create a table −mysql> create table demo23 −> ( −> id int not null auto_increment primary key, −> value1 int, −> value2 int −> ); Query OK, 0 rows affected (1.65 sec)Insert some records into ... Read More

AmitDiwan
163 Views
For this, use left join on table A and B. Let us create the first table −mysql> create table demo20 −> ( −> id int, −> name varchar(20) −> ); Query OK, 0 rows affected (1.87 sec)Insert some records into the table with the help of insert command −mysql> insert ... Read More

AmitDiwan
592 Views
Following is the correct syntax to use LIKE with search variable −String sqlQuery; sqlQuery = "select *from yourTableName where yourColumnName like '%" +yourSearchVariableName + "%'";Let us create a table −mysql> create table demo19 −> ( −> id int not null auto_increment primary key, −> name varchar(50) −> ); Query OK, ... Read More

AmitDiwan
749 Views
Use ORDER BY with some cases. Let us create a table −mysql> create table demo18 −> ( −> value text −> ); Query OK, 0 rows affected (1.18 sec)Insert some records into the table with the help of insert command −mysql> insert into demo18 values('John Smith'); Query OK, 1 row ... Read More