Actually, it is not possible to prepare all SQL statements because MySQL only allows the following kinds of SQL statements that can be prepared:SELECT statementsExamplemysql> PREPARE stmt FROM 'SELECT tender_value from Tender WHERE Companyname = ?'; Query OK, 0 rows affected (0.09 sec) Statement prepared mysql> SET @A = 'Singla Group.'; Query OK, 0 rows affected (0.00 sec) mysql> EXECUTE stmt using @A; +--------------+ | tender_value | +--------------+ | 220.255997 | +--------------+ 1 row in set (0.07 sec) mysql> DEALLOCATE PREPARE stmt; Query OK, 0 rows affected (0.00 sec)INSERT, REPLACE, UPDATE and DELETEstatements that modify the ... Read More
We can use both INSTR() function and LIKE operator to search or match a particular pattern and they return same result. It can be demonstrated from the following example of ‘Student’ table.ExampleSuppose we want to search name, which contains ‘av’ in it, from ‘Student’ table. We can use INSTR() function as follows −mysql> Select Name from student where INSTR(name, 'av') > 0; +--------+ | Name | +--------+ | Gaurav | | Aarav | | Gaurav | +--------+ 3 rows in set (0.00 sec)Now, for the same kind of search we can use LIKE operator as follows −mysql> Select Name ... Read More
It can be understood with the help of following the example in which we have created the table named ‘Student’ by using prepared statement −mysql> PREPARE stmt3 FROM 'CREATE TABLE Student(Id INT, Name Varchar(20))'; Query OK, 0 rows affected (0.00 sec) Statement prepared mysql> EXECUTE stmt3; Query OK, 0 rows affected (0.73 sec) mysql> DEALLOCATE PREPARE stmt3; Query OK, 0 rows affected (0.00 sec)Now, with the help of following queries using prepared statements, we can insert the valuesin table ‘Student’ −mysql> PREPARE stmt7 FROM 'INSERT INTO Student(Id, Name) values(?, ?)'; Query OK, 0 rows affected (0.00 sec) Statement ... Read More
It can be understood with the help of following the example in which we have updated the table named ‘Student’, having the following data, by using prepared statement −mysql> Select * from Student; +------+-------+ | Id | Name | +------+-------+ | 1 | Ram | | 2 | Shyam | | 3 | Mohan | +------+-------+ 3 rows in set (0.00 sec) mysql> PREPARE stmt11 FROM 'UPDATE Student SET Name = ? WHERE Id = ?'; Query OK, 0 rows affected (0.03 sec) Statement prepared mysql> SET @A = 'Sohan', @B = 3; ... Read More
Cloning in C# is useful if you want to clone an array. The Clone() method in C# is used to create a similar copy of the array. C# has the Clone method and ICloneable interface.Let us see an example to clone an array using the Clone() method −Example Live Demousing System; class Program { static void Main() { string[] arr = { "one", "two", "three", "four", "five" }; string[] arrCloned = arr.Clone() as string[]; Console.WriteLine(string.Join(", ", arr)); Console.WriteLine(string.Join(", ", arrCloned)); Console.WriteLine(); } ... Read More
For using it with column’s data we need to provide column name as the argument of REPLACE() function. It can be demonstrated by using ‘Student’ table data as follows −Examplemysql> Select Id, Name, Subject, REPLACE(Subject, 's', ' Science') from Student WHERE Subject = 'Computers'; +------+--------+-----------+-----------------------------------+ | Id | Name | Subject | REPLACE(Subject, 's', ' Science') | +------+--------+-----------+-----------------------------------+ | 1 | Gaurav | Computers | Computer Science | | 20 | Gaurav | Computers | Computer Science | +------+--------+-----------+-----------------------------------+ 2 rows in set (0.00 sec)
To empty an array in C#, use the Array Clear() method: The Array.Clear method in C# clears i.e.zeros out all elements.In the below example, we have first considered an array with three elements −int[] arr = new int[] {88, 45, 76};Now we have used the Array.Clear method to zero out all the arrays −Array.Clear(arr, 0, arr.Length);Let us see an example of Array.Clear method in c# −Example Live Demousing System; class Program { static void Main() { int[] arr = new int[] {88, 45, 76}; Console.WriteLine("Array (Old):"); foreach (int val in arr) ... Read More
MySQL REVERSE() function make it possible to invert a string. Its syntax is as follows −SyntaxREVERSE(STR)Here, STR is a string which we want to invert.Examplemysql> Select REVERSE('MySQL'); +------------------+ | REVERSE('MySQL') | +------------------+ | LQSyM | +------------------+ 1 row in set (0.05 sec)
If you want to pass arguments by command line, then use command line arguments in C# −When we create a program in c#, static void main is used and we can see the arguments in it .class HelloWorld { static void Main(string[] args) { /* my first program in C# */ Console.WriteLine("Hello World"); Console.ReadKey(); }The string[] args is a variable that has all the values passed from the command line as shown above.Now to print those arguments, let’s say we have an argument, “One” −Console.WriteLine("Length of the arguments: "+args.Length); ... Read More
The sizeof() datatype returns the size of a data type. Let’s say you need to find the size of int datatype −sizeof(int);For double datatypesizeof(double);Let us see the complete example to find the size of various datatypes −Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { Console.WriteLine("The size of int is {0}", sizeof(int)); Console.WriteLine("The size of int is {0}", sizeof(char)); Console.WriteLine("The size of short is {0}", sizeof(short)); Console.WriteLine("The size of long is ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP