Ankith Reddy has Published 996 Articles

Implement MySQL INSERT MAX()+1?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

2K+ Views

You need to use COALESCE() function for this. The syntax is as follows:INSERT INTO yourTableName(yourColumnName1, yourColumnName2) SELECT 1 + COALESCE((SELECT MAX(yourColumnName1) FROM yourTableName WHERE yourColumnName2=’yourValue’), 0), ’yourValue’;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table InsertMaxPlus1Demo    -> ... Read More

MySQL select distinct dates from datetime column in a table?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

5K+ Views

You need to use DISTINCT keyword to select distinct dates from datetime column in a table.For an example, let us create a tablemysql> create table PostMesssageDemo    - > (    - > UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > UserMessage varchar(100),    - > UserPost datetime ... Read More

How to use IF in stored procedure and select in MySQL?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

605 Views

You can use IF in stored procedure and IF() in select statement as well.IF() in select statementIF() in select statement mysql> select if(0=0, 'Hello MySQL', 'condition is wrong');This will produce the following output −+------------------------------------------------------+ | if('test'='test', 'Hello MySQL', 'condition is wrong') | +------------------------------------------------------+ | Hello MySQL ... Read More

Earliest data output time considering TOE in 8085 Microprocessor

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

157 Views

The 8085AH activates the RD* Signal at 270 nS. This signal moves to OE* pin of 27128 through the octal line driver 74LS241 delayed by 12nS. Hence the signal OE* signal is received by 27128 at the end of time 282 nS. Hence the data can only come out from ... Read More

Adding a column whose value is not null by default in MySQL?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

1K+ Views

For this, you need to remove the default keyword. The syntax is as follows:ALTER TABLE yourTableName ADD COLUMN yourColumnName dataType NOT NULL AFTER yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table AddingColumnDefaultValueNOTNULL    -> (    -> ... Read More

How to convert US date format to MySQL format in INSERT query?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

327 Views

You can use STR_TO_DATE() to convert US date format to MySQL format in INSERT. Let us first create a table −mysql>create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ShippingDatetime varchar(200) ); Query OK, 0 rows affected (1.04 sec)Insert some records in the table using insert ... Read More

Programs Using Interface Modules

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

550 Views

We use a logic controller and it is used in industry for the process of control done by the software. Multiple inputs are typically accepted which performs a total complete sequence of operations carried out both arithmetic and logically. The outputs generated are used for the maintenance of the process ... Read More

How to correctly implement END IF statement in a MySQL Stored Procedure?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

254 Views

The following is the syntax of END IF statement in MySQLIF yourCondition THEN yourStatement ELSE yourStatement END IFHere is the demo of END IF statement while creating a stored proceduremysql> DELIMITER // mysql> CREATE PROCEDURE Sp_Test( IN value INT ) - ... Read More

Simulation of 4-bit ALU

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

2K+ Views

Moreover, we write an assembly program in 8085 assembly language just to simulate a 4-bit ALU by using an interface which is based on the logic controller. The Arithmetic Logical Unit always performs an addition, subtraction, AND operation, or OR operation, which is based on the 4-bit inputs for the ... Read More

ArrayBlockingQueue remainingCapacity() Method in Java

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

90 Views

The remainingCapacity() method of the ArrayBlockingQueue class in Java is used to return the number of additional elements that the queue can adopt without blocking.The syntax is as followsint remainingCapacity()To work with ArrayBlockingQueue class, you need to import the following packageimport java.util.concurrent.ArrayBlockingQueue;The following is an example to implement remainingCapacity() method ... Read More

Advertisements