Working with MySQL WHERE OR Query with Multiple OR Usage

AmitDiwan
Updated on 26-Aug-2019 08:02:28

185 Views

Yes, an alternative for MySQL “WHERE.. OR” is using REGEXP.Let us first create a table −mysql> create table DemoTable684(EmployeeInformation text); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable684 values('John 21 Google'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable684 values('Carol 23 Amazon'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable684 values('Carol 26 Flipkart'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable684 values('David 29 Microsoft'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> ... Read More

Write MySQL Query to Select First 10 Records

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

1K+ Views

To select first 10 records, we can first order the records in ascending or descending order. With that, use LIMIT 10 to get only 10 records −select *from (select *from yourTableName ORDER BY yourColumnName ASC LIMIT 10)anyAliasName ORDER BY yourColumnName DESC;Let us first create a table −mysql> create table DemoTable683(Page int); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable683 values(100); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable683 values(101); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable683 values(102); Query OK, 1 row affected ... Read More

Use NOT IN, OR and IS NULL in MySQL Query

AmitDiwan
Updated on 26-Aug-2019 07:41:36

130 Views

Let us first create a table −mysql> create table DemoTable793(    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(100) ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable793(StudentName) values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable793(StudentName) values('Bob'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable793(StudentName) values(null); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable793(StudentName) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable793(StudentName) values('Robert'); Query OK, 1 row affected (1.03 sec)Display all records from ... Read More

Concatenate String with Numbers in MySQL

AmitDiwan
Updated on 26-Aug-2019 07:34:42

1K+ Views

To concatenate string with numbers, use the CONCAT() method. Let us first create a table −mysql> create table DemoTable682(    Name varchar(100),    Age int ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable682 values('John', 23); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable682 values('Chris', 21); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable682 values('David', 25); Query OK, 1 row affected (0.17 sec) Display all records from the table using select statement:Display all records from the table using select statement -mysql> select *from ... Read More

Select Date Records Between Two Dates in MySQL

AmitDiwan
Updated on 26-Aug-2019 07:31:39

2K+ Views

To select the date records between two dates, you need to use the BETWEEN keyword. Let us first create a table −mysql> create table DemoTable681(AdmissionDate datetime); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable681 values('2019-01-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-11-01'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-12-03'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-07-03'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable681 values('2019-02-04'); Query OK, 1 row affected (0.34 ... Read More

Order and Return Duplicate Column Values Only Once in MySQL

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

165 Views

To return a column value only once in MySQL, let us first see an example and create a table −mysql> create table DemoTable680(Status varchar(100)); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable680 values('Busy'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable680 values('At Work'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable680 values('Busy'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable680 values('Blocked'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable680 values('Offline'); Query OK, 1 row affected (0.67 sec) ... Read More

Types of Relations

Mahesh Parahar
Updated on 26-Aug-2019 07:22:45

763 Views

The Empty Relation between sets X and Y, or on E, is the empty set ∅The Full Relation between sets X and Y is the set X × YThe Identity Relation on set X is the set { (x, x) | x ∈ X }The Inverse Relation R' of a relation R is defined as − R' = { (b, a) | (a, b) ∈ R }Example − If R = { (1, 2), (2, 3) } then R' will be { (2, 1), (3, 2) }A relation R on set A is called Reflexive if ∀ a ∈ A ... Read More

Theory of Inference for the Statement Calculus

Mahesh Parahar
Updated on 26-Aug-2019 07:18:26

5K+ 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 “$\therefore$”, (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

Order Records and Fetch Using MySQL LIMIT

AmitDiwan
Updated on 26-Aug-2019 07:16:39

133 Views

Let us first create a table −mysql> create table DemoTable679(FirstName varchar(100)); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable679 values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable679 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable679 values('David'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable679 values('Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable679 values('Mike'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable679 values('Sam'); Query OK, 1 row affected (0.15 sec) mysql> insert ... Read More

Sum of Degrees of Vertices Theorem

Mahesh Parahar
Updated on 26-Aug-2019 07:14:19

709 Views

If G = (V, E) be a non-directed graph with vertices V = {V1, V2, …Vn} thenn ∑ i=1 deg(Vi) = 2|E|Corollary 1If G = (V, E) be a directed graph with vertices V = {V1, V2, …Vn}, thenn ∑ i=1 deg+(Vi) = |E| = n ∑ i=1 deg−(Vi)Corollary 2In any non-directed graph, the number of vertices with Odd degree is Even.Corollary 3In a non-directed graph, if the degree of each vertex is k, thenk|V| = 2|E|Corollary 4In a non-directed graph, if the degree of each vertex is at least k, thenk|V| = 2|E|Corollary 5In a non-directed graph, if the ... Read More

Advertisements