AmitDiwan has Published 10744 Articles

Should I use a loop or 'OR' operator to query a bunch of stuff at a fast pace In MYSQL?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:50:49

112 Views

For faster querying, you need to use MySQL IN(). Let us first create a table −mysql> create table DemoTable1538    -> (    -> ClientId int,    -> ClientName varchar(20)    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to create a column of months from date and display sum of the corresponding column wherein you find duplicate dates?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:49:47

80 Views

For this can use DATE_FORMAT() in MySQL. Let us first create a table −mysql> create table DemoTable    -> (    -> PurchaseDate date,    -> Amount int    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More

How to write a single MySQL query for displaying a value for multiple inputs?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:47:28

314 Views

For this, use BETWEEN keyword. Let us first create a table −mysql> create table DemoTable1537    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20)    -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> ... Read More

Using Update statement with TINYINT in MySQL?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:46:35

2K+ Views

Let us first create a table. We have set one of the columns with type TINYINT −mysql> create table DemoTable    -> (    -> EmployeeId int,    -> isMarried tinyint    -> ); Query OK, 0 rows affected (6.84 sec)Insert some records in the table using insert command −mysql> ... Read More

A single MySQL query to search multiple words from different column values

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:44:51

2K+ Views

For this, you can use WHERE clause with multiple LIKE. Let us first create a table −mysql> create table DemoTable1536    -> (    -> Sentence text    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1536 values('I ... Read More

MySQL Order by beginning letter?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:42:42

619 Views

To order by the first letter, use ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable1535    -> (    -> Value varchar(100)    -> ); Query OK, 0 rows affected (2.26 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1535 ... Read More

Implement multiple LIKE operators in a single MySQL query

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:40:27

854 Views

To implement multiple LIKE clauses, the syntax is as follows −select * from yourTableName  where yourColumnName1 LIKE ('%yourValue1%' or yourColumnName2 LIKE '%yourValue2%') or (yourColumnName3 LIKE '%yourValue3');Let us first create a table −mysql> create table DemoTable1534    -> (    -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientName ... Read More

Count(*) rows from multiple tables in MySQL?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:36:17

1K+ Views

To count rows from multiple tables in MySQL, the syntax is as follows −Select     (select count(*) from yourTableName1) as anyAliasName1,     (select count(*) from yourTableName2) as anyAliasName2     from dual;Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int ... Read More

Order a column in MySQL with IP Address records?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:35:07

687 Views

For this, use INET_ATON() in MySQL. The INET_ATON() method would allow a user to convert IP Address records to a number and then we can use ORDER BY to order them.Let us first create a table −mysql> create table DemoTable    -> (    -> IpAddress varchar(50)    -> ); ... Read More

MySQL equivalent to Sybase ASE command?

AmitDiwan

AmitDiwan

Updated on 12-Dec-2019 05:34:05

214 Views

The MySQL equivalent to sybase ASE command is EXPLAIN keyword. Let us first create a table −mysql> create table DemoTable1531    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20)    -> ); Query OK, 0 rows affected (2.92 sec) mysql> create index Name_index1 ... Read More

Advertisements