Karthikeya Boyini has Published 2383 Articles

Get the maximum count of distinct values in a separate column with MySQL

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 11:19:22

342 Views

Use COUNT() function along with GROUP BY clause for this. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 ... Read More

Truncate results in decimal to integer value with MySQL

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 11:18:07

425 Views

Use truncate() for this, for example, 190.245 to 190. Following is the syntax −select truncate(yourColumnName, 0) from yourTableName;Let us first create a table −mysql> create table DemoTable    -> (    -> Value DECIMAL(10, 4)    -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table ... Read More

Selecting records within a range and with a condition set on two columns in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 11:16:59

369 Views

For this, use where clause. Let us first create a table −mysql> create table DemoTable -> ( -> Number1 int, -> Number2 int -> ); Query OK, 0 rows affected (3.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(40, 50); Query OK, 1 row ... Read More

MySQL query to fecth the domain name from email-id?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 11:15:33

565 Views

Use SUBSTRING_INDEX() for this. Let us first create a table −mysql> create table DemoTable -> ( -> UserMailId varchar(100) -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John@gmail.com'); Query OK, 1 row affected (0.20 sec) mysql> ... Read More

What is Piggybacking in Networking?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 10:59:35

12K+ Views

In reliable full - duplex data transmission, the technique of hooking up acknowledgments onto outgoing data frames is called piggybacking.Why Piggybacking?Communications are mostly full – duplex in nature, i.e. data transmission occurs in both directions. A method to achieve full – duplex communication is to consider both the communication as ... Read More

How can I get the list of files in a directory using C or C++?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 10:47:33

12K+ Views

Let us consider the following C++ sample code to get the list of files in a directory.AlgorithmBegin    Declare a poniter dr to the DIR type.    Declare another pointer en of the dirent structure.    Call opendir() function to open all file in present directory.    Initialize dr pointer ... Read More

How to filter a specific month in MySQL when date is in varchar?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:59:50

342 Views

To filter, you can use STR_TO_DATE() function from MySQL. With that, use MONTH() to get the date from the specific month. Let us first create a table −mysql> create table DemoTable    -> (   -> DueDate varchar(100)    -> ); Query OK, 0 rows affected (1.18 sec)Insert some records ... Read More

How to sort an alphanumeric column in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:58:33

558 Views

To sort an alphanumeric column, use LIKE operator along with SUBSTRING(). Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId varchar(100)    -> ); Query OK, 0 rows affected (1.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More

How to use a single MySQL query to count column values ignoring null?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:57:40

112 Views

For this, you can COUNT() method, which does not include NULL value. Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(100),    -> CountryName varchar(100)    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert ... Read More

Implement MySQL LIMIT and OFFSET in a single query stating its difference

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:56:32

614 Views

The LIMIT tells about how many records you want while OFFSET gives the records from the given position+1. Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(100)    -> ); Query OK, 0 rows affected (1.33 sec)Insert some records in the table ... Read More

Advertisements