MySQL Returns with Enclosed Set of Unit Values Using INTERVAL Keyword

Vrundesha Joshi
Updated on 30-Jan-2020 05:19:14

123 Views

In this case, MySQL will take into consideration the first value out of two provided in the enclosed set of unit values. It will return the output along with warning after calculating the interval, based on the considered value from an enclosed set, on the unit given in INTERVAL keyword. The following example will clarify it −mysql> Select TIMESTAMP('2017-10-22 04:05:36' + INTERVAL '4 2' Hour)AS 'HOUR VALUE INCREASED BY 4'; +---------------------------+ | HOUR VALUE INCREASED BY 4 | +---------------------------+ | 2017-10-22 08:05:36       | +---------------------------+ 1 row in set, 1 warning (0.00 sec) mysql> Show warnings; +---------+------+------------------------------------------+ | ... Read More

Sort MySQL Output Based on a Non-Result Set Column

Lakshmi Srinivas
Updated on 30-Jan-2020 05:18:16

183 Views

It is quite possible to get the sorted output on the basis of the column which is not even the part of that output or not in the result set. It can be done by selecting the required fields and writing the name of the fields on the basis of which sorting order is desired. Following is an example to demonstrate it, in which we sorted out the result set, having ‘Name’ and ‘Address’ fields, on the basis of column ‘id’.mysql> Select Name, Subject From Student ORDER BY Id; +---------+-----------+ | Name    | Subject   | +---------+-----------+ | Gaurav ... Read More

What MySQL Returns with Time Components in DATEDIFF Function

Ramu Prasad
Updated on 30-Jan-2020 05:17:21

121 Views

MySQL DATEDIFF() function also works with date and time values but it ignores the time value. Hence even if we include the time value in DATEDIFF() function MySQL will return the difference, in days, between dates by ignoring the time values.mysql> Select DATEDIFF('2018-10-22 04:05:36', '2017-10-22 03:05:45'); +-------------------------------------------------------+ | DATEDIFF('2018-10-22 04:05:36', '2017-10-22 03:05:45') | +-------------------------------------------------------+ |                                                   365 | +-------------------------------------------------------+ 1 row in set (0.00 sec) mysql> Select DATEDIFF('2017-10-22 04:05:36', '2017-10-22 03:05:45'); +-------------------------------------------------------+ | DATEDIFF('2017-10-22 04:05:36', ... Read More

C Program for File Transfer Using UDP

Arnab Chakraborty
Updated on 29-Jan-2020 12:18:08

2K+ Views

Data can be shifted between two computers implementing Socket programming in C.In same case, files can easily be sent implementing User Datagram Protocol(UDP) and a simple client/server.Security − Handled by encryption.Protocol − UDPEncryption − XOR encryptionAlgorithmThe server is started and waited for filename.A filename is sent by the client.This filename is received by the server. If file is present, server starts reading file and is continued to send a buffer filled with file contents encrypted until and unless file-end is reached.End of File is marked by EOF.File is received as buffers until and unless EOF is received. After that it ... Read More

Binary Tree to Binary Search Tree Conversion using STL Set in C++

Arnab Chakraborty
Updated on 29-Jan-2020 12:11:48

754 Views

In case of a given Binary Tree, convert it to a Binary Search Tree in such a way that keeps the original structure of Binary Tree intact.Sets of C++ STL will be used by this solution instead of array based solution.ExamplesExample 1Input     11     /  \    3    8 /     \ 9 5Output     9    /   \   5     11  /        \ 3        8Example 2Input      11      /   \     31    16    /        \  21 ... Read More

Binomial Heap in C++

Arnab Chakraborty
Updated on 29-Jan-2020 12:10:57

518 Views

Binomial Heap is defined as an extension of Binary Heap that provides faster merge or union operation together with other operations provided by Binary Heap.A Binomial Heap is treated as a collection of Binomial Trees.What is a Binomial Tree?A Binomial Tree of order k can be built by taking two binomial trees of order k-1 and treating one as leftmost child or other.A Binomial Tree of order k has below properties.The number of nodes of Binomial Tree has exactly 2k.The depth of Binomial Tree is k.There are exactly kCi nodes at depth i where i = 0, 1, . . ... Read More

Binary Number System Overflow in Arithmetic Addition in C/C++

Arnab Chakraborty
Updated on 29-Jan-2020 11:43:59

904 Views

2’s Complement Number System is widely implemented in computer architecture.N-bit 2’s Complement number System can be able to represent Number from -2n-1 to 2n-1- 14 Bit can be able to represent numbers from ( -8 to 7 )5 Bit can be able to represent numbers from ( -16 to 15 ) in 2’s Complementary System.Overflow happens with respect to addition when 2 N-bit 2’s Complement Numbers are appended and the answer is too large to fit into that N-bit Group.A computer contains N-Bit Fixed registers. Result of addition of two N-Bit Number will result maximum N+1 Bit number.Carry Flag stores ... Read More

Binary Indexed Tree or Fenwick Tree in C++

Arnab Chakraborty
Updated on 29-Jan-2020 11:11:23

461 Views

In case of comparing with a flat array of numbers, the Fenwick tree results a much better balance between two operations: element update and prefix sum computation. In case of a flat array of m numbers, we can either store the elements, or the prefix sums. In case of first instance, calculating prefix sums needs linear time; in case of second instance, modifying or updating the array elements needs linear time (in both instances, the other operation can be accomplished in constant time). Fenwick trees permit both operations to be accomplished in O(log m) time. This is obtained by representing ... Read More

Calling a Function in Python

Mohd Mohtashim
Updated on 29-Jan-2020 11:10:26

528 Views

Defining a function only gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code.Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following is the example to call printme() function − Live Demo#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme("I'm first call to user defined function!") printme("Again second call to the same function")OutputWhen ... Read More

The Calendar Module in Python

Mohd Mohtashim
Updated on 29-Jan-2020 11:09:25

621 Views

The calendar module supplies calendar-related functions, including functions to print a text calendar for a given month or year.By default, calendar takes Monday as the first day of the week and Sunday as the last one. To change this, call calendar.setfirstweekday() function.Here is a list of functions available with the calendar module −Sr.NoFunction with Description1calendar.calendar(year, w=2, l=1, c=6)Returns a multiline string with a calendar for year year formatted into three columns separated by c spaces. w is the width in characters of each date; each line has length 21*w+18+2*c. l is the number of lines for each week.2calendar.firstweekday( )Returns the current setting ... Read More

Advertisements