Karthikeya Boyini has Published 2193 Articles

How to order by timestamp in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 11:28:26

1K+ Views

To order by timestamp, use the ORDER BY as in the following syntax −select *from yourTableName ORDER BY STR_TO_DATE(`yourColumnName`, '%m/%d/%Y%h:%i:%s %p');Let us first create a table −mysql> create table DemoTable    -> (    -> `timestamp` varchar(100)    -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in ... Read More

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

431 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

562 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

421 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

772 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

16K+ 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 to filter a specific month in MySQL when date is in varchar?

karthikeya Boyini

karthikeya Boyini

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

433 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

736 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

163 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

681 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