Order By Date Set with Varchar Type in MySQL

AmitDiwan
Updated on 26-Aug-2019 07:13:10

582 Views

For this, use ORDER BY STR_TO_DATE in MySQL as in the below syntax −select *from yourTableName ORDER BY STR_TO_DATE(yourColumnName, '%M %Y') DESC;Let us first create a table −mysql> create table DemoTable678(DueDate varchar(200)); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. We have inserted dates here −mysql> insert into DemoTable678 values('March 2019'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable678 values('November 2018'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable678 values('January 2019'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> ... Read More

Set Theory

Mahesh Parahar
Updated on 26-Aug-2019 07:11:23

2K+ Views

German mathematician G. Cantor introduced the concept of sets. He had defined a set as a collection of definite and distinguishable objects selected by the means of certain rules or descriptions.Set theory forms the basis of several other fields of study like counting theory, relations, graph theory, and finite state machines. In this chapter, we will cover the different aspects of Set Theory.Set - DefinitionA set is an unordered collection of different elements. A set can be written explicitly by listing its elements using a set bracket. If the order of the elements is changed or any element of a ... Read More

MySQL Order By with Custom Field Value

AmitDiwan
Updated on 26-Aug-2019 07:08:35

476 Views

To set custom field value, use FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable677(    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserStatus text ); Query OK, 0 rows affected (1.07 sec)Insert some records in the table using insert command −mysql> insert into DemoTable677(UserStatus) values('BUSY'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable677(UserStatus) values('AT WORK'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable677(UserStatus) values('OFFLINE'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable677(UserStatus) values('BLOCKED'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select ... Read More

Set Operations

Mahesh Parahar
Updated on 26-Aug-2019 07:06:42

9K+ Views

Venn diagram, invented in 1880 by John Venn, is a schematic diagram that shows all possible logical relations between different mathematical sets.ExamplesSet OperationsSet Operations include Set Union, Set Intersection, Set Difference, Complement of Set, and Cartesian Product.Set UnionThe union of sets A and B (denoted by A ∪ B) is the set of elements that are in A, in B, or in both A and B. Hence, A ∪ B = { x | x ∈ A OR x ∈ B }.Example − If A = { 10, 11, 12, 13 } and B = { 13, 14, 15 }, ... Read More

Concatenate Column Values with Prefix in MySQL

AmitDiwan
Updated on 26-Aug-2019 07:03:50

603 Views

The CONCAT() method would be used to concatenate “MR” to every string, whereas GROUP_CONCAT() to concatenate some of the column values in a single line.Let us first see an example and create a table −mysql> create table DemoTable799(    UserId int,    UserName varchar(100),    UserAge int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable799 values(101, 'John', 21); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable799 values(102, 'Chris', 26); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable799 values(101, 'Robert', 23); Query OK, ... Read More

Rules of Inference for Predicate Calculus

Mahesh Parahar
Updated on 26-Aug-2019 07:00:24

2K+ Views

To deduce new statements from the statements whose truth that we already know, Rules of Inference are used.What are Rules of Inference for?Mathematical logic is often used for logical proofs. Proofs are valid arguments that determine the truth values of mathematical statements.An argument is a sequence of statements. The last statement is the conclusion and all its preceding statements are called premises (or hypothesis). The symbol “∴”, (read therefore) is placed before the conclusion. A valid argument is one where the conclusion follows from the truth values of the premises.Rules of Inference provide the templates or guidelines for constructing valid ... Read More

Display Records with Latest ID in a MySQL Table

AmitDiwan
Updated on 26-Aug-2019 06:53:39

253 Views

Let us first create a table −mysql> create table DemoTable676(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Number int ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable676(Number) values(1000); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable676(Number) values(1839); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable676(Number) values(29894); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable676(Number) values(1264); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable676(Number) values(190); Query OK, 1 row affected (0.17 sec) mysql> insert into ... Read More

Rooted and Binary Tree

Mahesh Parahar
Updated on 26-Aug-2019 06:51:32

5K+ Views

Rooted TreeA rooted tree G is a connected acyclic graph with a special node that is called the root of the tree and every edge directly or indirectly originates from the root. An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered. If every internal vertex of a rooted tree has not more than m children, it is called an m-ary tree. If every internal vertex of a rooted tree has exactly m children, it is called a full m-ary tree. If m = 2, the rooted tree is called a binary tree.Binary ... Read More

Search Within a Table of Comma-Separated Values in MySQL

AmitDiwan
Updated on 26-Aug-2019 06:48:43

499 Views

To search within a table of comma-separated values, use LIKE operator. Let us first create a table −mysql> create table DemoTable675(Value text); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable675 values('10, 56, 49484, 93993, 211, 4594'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable675 values('4, 7, 1, 10, 90, 23'); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable675 values('90, 854, 56, 89, 10'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable675 values('11, 22, 344, 67, 89'); Query OK, 1 row ... Read More

Representation of Relations Using Graph

Mahesh Parahar
Updated on 26-Aug-2019 06:47:14

2K+ Views

A relation can be represented using a directed graph.The number of vertices in the graph is equal to the number of elements in the set from which the relation has been defined. For each ordered pair (x, y) in the relation R, there will be a directed edge from the vertex ‘x’ to vertex ‘y’. If there is an ordered pair (x, x), there will be a self- loop on vertex ‘x’.Suppose, there is a relation R = { (1, 1), (1,2), (3, 2) } on set S = { 1, 2, 3 }, it can be represented by the following graph −

Advertisements