George John has Published 1299 Articles

Sound-playing interface for Windows in Python (winsound)

George John

George John

Updated on 30-Jun-2020 09:25:07

The winsound module is specific to Python installation on Windows operating system. The module defines following functions −Beep()When this function is called a beep is heard from the PC’s speaker. The function needs two parameters. The frequency parameter specifies frequency of the sound, and must be in the range 37 ... Read More

A Simplex Stop-and-Wait Protocol for a Noisy Channel

George John

George John

Updated on 30-Jun-2020 08:12:32

Simplex Stop – and – Wait protocol for noisy channel is data link layer protocol for data communications with error control and flow control mechanisms. It is popularly known as Stop – and –Wait Automatic Repeat Request (Stop – and –Wait ARQ) protocol. It adds error control facilities to Stop ... Read More

What are the difference ways to replace nulls values in MySQL using SELECT statement?

George John

George John

Updated on 30-Jun-2020 07:57:57

There are lots of options available to replace NULL values using select statement. You can use CASE statement or IFNULL() or COALESCE()Case 1 − Using IFNULL()The syntax of IFNULL() is as follows −SELECT IFNULL(yourColumnName, ’yourValue’) AS anyVariableName from yourTableName;Case 2 − Using COALESCE()The syntax of COALESCE() is as follows −SELECT ... Read More

How can I change root username in MySQL?

George John

George John

Updated on 30-Jun-2020 07:45:45

To change the root username in MySQL, you need to use UPDATE and SET command. The syntax is as follows −UPDATE user set user = ’yourNewUserName’ WHERE user = ’root’;To understand the above syntax, let us switch the database to MySQL using USE command.The query is as follows to switch ... Read More

Replace 0 with null in MySQL?

George John

George John

Updated on 30-Jun-2020 07:36:05

You can use NULLIF() from MySQL to replace 0 with NULL. The syntax is as follows −SELECT *, NULLIF(yourColumnName, 0) as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table Replace0WithNULLDemo    -> (   ... Read More

MySQL LIMIT to select a single row

George John

George John

Updated on 30-Jun-2020 07:28:32

To select a single row in MySQL, you can use LIMIT. At first, let us create a table. The query to create a table is as follows −mysql> create table selectWithPrimaryKey    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Age int,   ... Read More

MySQL order by string with numbers?

George John

George John

Updated on 30-Jun-2020 07:20:00

To MySQL order string with numbers, the following is the syntax, wherein we have used ORDER BY, SUBSTR() and CAST() −SELECT *FROM yourTableName ORDER BY SUBSTR(yourColumnName FROM 1 FOR 2), CAST(SUBSTR(yourColumnName FROM 2) AS UNSIGNED);To understand the above syntax, let us create a table. The query to create a table ... Read More

MySQL select * with distinct id?

George John

George John

Updated on 30-Jun-2020 07:06:04

You can use GROUP BY command for select with distinct id. The syntax is as follows −SELECT *FROM yourTableName GROUP BY yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table DistinctIdDemo    -> (    -> Id ... Read More

Select distinct combinations from two columns in MySQL?

George John

George John

Updated on 30-Jun-2020 06:53:01

To select distinct combinations from two columns, you can use CASE statement. Let us create a table with some columns.The query to create a table is as follows −mysql> create table select_DistinctTwoColumns    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> FirstValue char(1),    -> SecondValue char(1), ... Read More

Order by last 3 chars in MySQL?

George John

George John

Updated on 30-Jun-2020 06:48:25

You can use ORDER BY RIGHT() function to order by last 3 chars in MySQL. The syntax is as follows −SELECT *FROM yourTableName ORDER BY RIGHT(yourColumnName, 3) yourSortingOrder;Just replace the ‘yourSortingOrder’ to ASC or DESC to set the ascending or descending order respectively.To understand the above syntax, let us create ... Read More

Advertisements