Vikyath Ram has Published 151 Articles

What kind of string comparison, case-sensitive or not, can be performed by MySQL?

Vikyath Ram

Vikyath Ram

Updated on 20-Jun-2020 13:46:14

158 Views

MySQL cannot perform a case-sensitive comparison when comparing characters. It can be illustrated with the following example from table ‘Employee’ having the following data −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | Salary | +----+--------+--------+ | 1  | Gaurav | 50000  | | 2  | Rahul ... Read More

How Can MySQL operator precedence affect result set?

Vikyath Ram

Vikyath Ram

Updated on 20-Jun-2020 13:05:49

130 Views

MySQL follows operator precedence and it has the following list of operators, having the same precedence which is on the same line −INTERVAL BINARY, COLLATE ! - (unary minus), ~ (unary bit inversion) ^ *, /, DIV, %, MOD -, + & | =, , >=, >,

How can we generate the same sequence of random numbers in MySQL?

Vikyath Ram

Vikyath Ram

Updated on 20-Jun-2020 13:01:46

148 Views

When invoked with an integer argument, RAND( ) uses that value to seed the random number generator. Each time you seed the generator with a given value, RAND( ) will produce the same sequence of random numbers. Following example will demonstrate it −Examplemysql> Select RAND(1), RAND(1), Rand(1); +---------------------+---------------------+---------------------+ | RAND(1) ... Read More

What MySQL returns if the search string, provided in FIELD() function, is NULL?

Vikyath Ram

Vikyath Ram

Updated on 20-Jun-2020 08:42:50

64 Views

As we know that NULL fails equality comparison with any value hence if the search string, provided in FIELD() function, is NULL then MySQL returns 0 as output.Examplemysql> Select FIELD(NULL,'Ram','is','good','boy'); +-------------------------------------+ | FIELD(NULL,'Ram','is','good','boy') | +-------------------------------------+ |                                   0 | +-------------------------------------+ 1 row in set (0.00 sec)

How can we get all the unique rows in MySQL result set?

Vikyath Ram

Vikyath Ram

Updated on 20-Jun-2020 07:09:52

176 Views

With the help of DISTINCT keyword in SELECT statement, we can get the unique rows in MySQL result set.Examplemysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | ... Read More

How can we emulate CHECK CONSTRAINT by using views?

Vikyath Ram

Vikyath Ram

Updated on 19-Jun-2020 13:39:38

52 Views

As we know that MySQL supports foreign key for referential integrity but it does not support CHECK constraint. But we can emulate them by using triggers. It can be illustrated with the help of an example given below −ExampleSuppose we have a table named ‘car1’ which can have the fix ... Read More

How can we apply the PRIMARY KEY constraint to the field of an existing MySQL table?

Vikyath Ram

Vikyath Ram

Updated on 19-Jun-2020 11:52:38

316 Views

We can apply the PRIMARY KEY constraint to a column of an existing MySQL table with the help of ALTER TABLE statement. SyntaxALTER TABLE table_name MODIFY colum_name datatype PRIMARY KEY;                  OR ALTER TABLE table_name ADD PRIMARY KEY (colum_name); Suppose we have the following table ... Read More

How to create Variables and Constants in C++?

Vikyath Ram

Vikyath Ram

Updated on 19-Jun-2020 09:05:05

131 Views

To define a variable in  C++, you need to use the following syntax −Syntaxdatatype variable_name;You need to know what type of data is your variable is going to hold and what it will be called. The variable name has constraints on what you can name it. Following are the rules ... Read More

C++ Programming Language Features

Vikyath Ram

Vikyath Ram

Updated on 18-Jun-2020 13:20:55

469 Views

C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. It is a superset of C, and that virtually any legal C program is a legal C++ program. C++ runs on a variety of platforms, such as Windows, Mac OS, and ... Read More

Factorial program in Java without using recursion.

Vikyath Ram

Vikyath Ram

Updated on 18-Jun-2020 08:09:48

1K+ Views

Following is the required program.ExampleLive Demopublic class Tester {    static int factorial(int n) {       if (n == 0)          return 1;       else          return (n * factorial(n - 1));    }    public static void main(String args[]) {       int i, fact = 1;       int number = 5;       fact = factorial(number);       System.out.println(number + "! = " + fact);    } }Output5! = 120

Previous 1 ... 3 4 5 6 7 ... 16 Next
Advertisements