For this, use DATE_FORMAT() in MySQL. The syntax is as follows −Exampleselect date_format(yourColumnName, '%d-%m-%Y') as anyAliasName from yourTableName;Let us create a table −Examplemysql> create table demo80 -> ( -> due_date date -> ); Query OK, 0 rows affected (0.74Insert some records into the table with the help of insert command −Examplemysql> insert into demo80 values('2020-04-30'); Query OK, 1 row affected (0.14 mysql> insert into demo80 values('2016-01-10'); Query OK, 1 row affected (0.17 mysql> insert into demo80 values('2018-03-21'); Query OK, 1 row affected (0.12Display records from the table using select statement −Examplemysql> select *from demo80;This will ... Read More
For this, you can use substring_index() in MySQL. Let us create a table −Examplemysql> create table demo79 -> ( -> fullname varchar(50) -> ); Query OK, 0 rows affected (0.64Insert some records into the table with the help of insert command −Examplemysql> insert into demo79 values("John, Smith"); Query OK, 1 row affected (0.09 mysql> insert into demo79 values("David, Miller"); Query OK, 1 row affected (0.11 mysql> insert into demo79 values("Chris, Brown"); Query OK, 1 row affected (0.07Display records from the table using select statement −Examplemysql> select *from demo79;This will produce the following output −Output+--------------+ | ... Read More
To get username using ID from two tables, you need to use JOIN and join the tables.Let us create a table −Examplemysql> create table demo77 -> ( -> userid int not null primary key, -> username varchar(20) -> ); Query OK, 0 rows affected (2.63Insert some records into the table with the help of insert command −Examplemysql> insert into demo77 values(1, 'John'); Query OK, 1 row affected (0.19 mysql> insert into demo77 values(2, 'Bob'); Query OK, 1 row affected (0.36Display records from the table using select statement −Examplemysql> select *from demo77;This will produce the following ... Read More
To find all users with unique last name, use GROUP BY HAVING COUNT().Let us create a table −Examplemysql> create table demo76 -> ( -> firstName varchar(20), -> lastName varchar(20) -> ); Query OK, 0 rows affected (9.29Insert some records into the table with the help of insert command −Examplemysql> insert into demo76 values('John', 'Doe'); Query OK, 1 row affected (2.52 mysql> insert into demo76 values('David', 'Smith'); Query OK, 1 row affected (6.31 mysql> insert into demo76 values('Adam', 'Smith'); Query OK, 1 row affected (1.52Display records from the table using select statement −Examplemysql> select *from ... Read More
For this, yYou can use from_unixtime() along with now().Let us create a table with some data type −Examplemysql> create table demo75 -> ( -> due_date int(11) -> ); Query OK, 0 rows affected, 1 warning (2.87Insert some records into the table with the help of insert command −Examplemysql> insert into demo75 values(unix_timestamp("2020-01-10")); Query OK, 1 row affected (0.46 mysql> insert into demo75 values(unix_timestamp("2020-11-19")); Query OK, 1 row affected (0.59 mysql> insert into demo75 values(unix_timestamp("2020-12-18")); Query OK, 1 row affected (0.44 mysql> insert into demo75 values(unix_timestamp("2020-11-10")); Query OK, 1 row affected (0.70Display records from the ... Read More
To implement LIKE query with dynamic array, the syntax is as follows −Exampleselect *from yourTableName where yourColumnName2 like "%yourValue%" order by yourColumnName1 asc limit yourLimitValue;Let us create a table −Examplemysql> create table demo74 -> ( -> user_id int not null auto_increment primary key, -> user_names varchar(250) -> ) -> ; Query OK, 0 rows affected (0.67Insert some records into the table with the help of insert command −Examplemysql> insert into demo74(user_names) values("John Smith1, John Smith2, John Smith3"); Query OK, 1 row affected (0.18 mysql> insert into demo74(user_names) values("John Smith1"); Query OK, ... Read More
To select all records with specific numbers, use the FIND_IN_SET() in MySQL.Let us create a table −Examplemysql> create table demo73 -> ( -> interest_id varchar(100), -> interest_name varchar(100) -> ); Query OK, 0 rows affected (1.48Insert some records into the table with the help of insert command −Examplemysql> insert into demo73 values("100, 101, 103, 105", "SSC"); Query OK, 1 row affected (0.34 mysql> insert into demo73 values("105, 103, 1005, 1003, 104", "Computer"); Query OK, 1 row affected (0.10 mysql> insert into demo73 values("110, 105, 104, 111", "Novel"); Query OK, 1 row affected (0.31Display records ... Read More
To convert, use str_to_date() in MySQLLet us create a table and add date records −Examplemysql> create table demo72 -> ( -> due_date varchar(40) -> ); Query OK, 0 rows affected (2.96 sec)Insert some records into the table with the help of insert command −Examplemysql> insert into demo72 values("11/15"); Query OK, 1 row affected (0.26 sec) mysql> insert into demo72 values("02/20"); Query OK, 1 row affected (0.09 sec) mysql> insert into demo72 values("07/95"); Query OK, 1 row affected (0.15 sec)Display records from the table using select statement −Examplemysql> select *from demo72;This will produce the following output ... Read More
SciPy library can be used to perform complex scientific computations at speed, with high efficiency. Nelder-Mead algorithm is also known as simple search algorithm.It is considered to be one of the best algorithms that can be used to solve parameter estimation problems, and statistical problems. Relevant to use this algorithm in situations where the values of functions are uncertain or have lots of noise associated with it.This algorithm can also be used to work with discontinuous functions which occur frequently in statistics. It is a simple algorithm and it is easy to understand as well. Used to minimize the parameters ... Read More
Finding the minimum of a scalar function is an optimization problem. Optimization problems help improve the quality of the solution, thereby yielding better results with higher performances. Optimization problems are also used for curve fitting, root fitting, and so on.Let us see an example −Exampleimport matplotlib.pyplot as plt from scipy import optimize import numpy as np print("The function is defined") def my_func(a): return a*2 + 20 * np.sin(a) plt.plot(a, my_func(a)) print("Plotting the graph") plt.show() print(optimize.fmin_bfgs(my_func, 0))OutputOptimization terminated successfully. Current function value: -23.241676 Iterations: 4 Function evaluations: 18 Gradient evaluations: 6 [-1.67096375]ExplanationThe required packages are imported.A ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP