Order By Clause in C#

Samual Sam
Updated on 22-Jun-2020 13:45:07

478 Views

The orderby is used in C# to sort elements in the collection based on specified fields in a particular order. The order can be ascending or descending.The following is our list with elements −List myList = new List(); // adding elements myList.Add("iOS by Apple"); myList.Add("Android by Google"); myList.Add("Symbian by Nokia");Now, use Orderby to order the elements in descending order −var myLen = from element in myList orderby element.Length descending select element;The following is the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       List myList = new ... Read More

Delete Existing MySQL Table Using PHP Function

Abhinanda Shri
Updated on 22-Jun-2020 13:44:39

145 Views

PHP uses mysql_query function to delete an existing MySQL table. This function takes two parameters and returns TRUE on success or FALSE on failure. Its syntax is as follows −Syntaxbool mysql_query( sql, connection );Followings are the parameters used in this function −S. No.Parameter & Description1.SqlRequired - SQL query to delete an existing MySQL table2.connectionOptional - if not specified, then the last opened connection by mysql_connect will be used.

Drop a MySQL View from the Database

Akshaya Akki
Updated on 22-Jun-2020 13:43:50

170 Views

With the help of DROP VIEW statement, we can drop a MySQL view from the database. Its syntax would be as follows −SyntaxDROP VIEW [IF EXISTS] view_name;Here view_name is the name of the view which we want to delete from the database.ExampleSuppose if we want to drop a view named info_less then the following query will delete if −mysql> DROP VIEW IF EXISTS Info_less; Query OK, 0 rows affected (0.03 sec)

Delete Existing MySQL Table Using PHP Script

Nitya Raut
Updated on 22-Jun-2020 13:43:01

244 Views

As we know that PHP provides us the function named mysql_query to delete an existing MySQL table.ExampleTo illustrate this we are deleting a table named ‘Tutorials_tbl’ with the help of PHP script in the following example −           Creating MySQL Tables                  

Get Definition of a MySQL View

Jai Janardhan
Updated on 22-Jun-2020 13:42:31

486 Views

As we know that views are a type of virtual tables and are the composition of tables too hence we can use the same query to get the definition of a view which we use to get the definition of a table. In other words, we can use SHOW CREATE statement to get the definition of a MySQL view. Its syntax would be as follows −SyntaxSHOW CREATE VIEW view_name;Here view_name is the name of the view of which we want to get the definition.ExampleThe following query will give the definition of a view named ‘info’ −mysql> Show Create View Info\G ... Read More

Get Structure of a MySQL View

Arjun Thakur
Updated on 22-Jun-2020 13:41:44

456 Views

As we know that views are a type of virtual tables and are a composition of tables too hence we can use the same query to get the structure of a view which we use to get the structure of a table. In other words, we can use DESCRIBE statement to get the structure of a MySQL view. Its syntax would be as follows −SyntaxDESCRIBE view_name;Here, view_name is the name of the view of which we want to get the structure.ExampleSuppose we want to get the structure of a view named ‘Info’ then it can be done with the help, of the following query ... Read More

C# Program to Return an Array from Methods

karthikeya Boyini
Updated on 22-Jun-2020 13:41:19

12K+ Views

Call a method under Join method to join words −string.Join(" ", display())Now set a string array −string[] str = new string[5];Add individual elements −str[0] = "My"; str[1] = "name"; str[2] = "is"; str[3] = "Brad"; str[4] = "Pitt";And return the same string array from method −return str;The following is the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       Console.WriteLine(string.Join(" ", display()));    }    static string[] display() {       string[] str = new string[5];       // string array elements       str[0] = "My";       str[1] = "name";       str[2] = "is";       str[3] = "Brad";       str[4] = "Pitt";       return str;    } }OutputMy name is Brad Pitt

Insert Data into MySQL Table using PHP

Srinivas Gorla
Updated on 22-Jun-2020 13:40:55

150 Views

PHP uses a mysql_query function to insert data into an existing MySQL table. This function takes two parameters and returns TRUE on success or FALSE on failure. Its syntax is as follows −Syntaxbool mysql_query( sql, connection );Followings are the parameters used in this function −S. No.Parameter & Description1.SqlRequired - SQL query to insert data into an existing MySQL table2.connectionOptional - if not specified, then the last opened connection by mysql_connect will be used.

C# Program to Get the Last Element from an Array

karthikeya Boyini
Updated on 22-Jun-2020 13:40:53

3K+ Views

Firstly, set an array −string[] str = new string[]{    "Java",    "HTML",    "jQuery",    "JavaScript",    "Bootstrap" };To get the value of the last element, get the length and display the following value −str[str.Length - 1]The above returns the last element.Here is the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       string[] str = new string[] {          "Java",          "HTML",          "jQuery",          "JavaScript",          "Bootstrap"       };       Console.WriteLine("Array...");       foreach(string res in str) {          Console.WriteLine(res);       }       Console.WriteLine("Last element: "+str[str.Length - 1]);    } }OutputArray... Java HTML jQuery JavaScript Bootstrap Last element: Bootstrap

Modify MySQL View with CREATE OR REPLACE VIEW Statement

Ayyan
Updated on 22-Jun-2020 13:40:10

509 Views

As we know that we can modify a view by using ALTER VIEW statement but other than that we can also use CREATE OR REPLACE VIEW to modify an existing view. The concept is simple as MySQL simply modifies the view if it already exists otherwise a new view would be created. Following is the syntax of it −SyntaxCREATE OR REPLACE VIEW view_name AS Select_statements FROM table;Examplemysql> Create OR Replace VIEW Info AS Select Id, Name, Address, Subject from student_info WHERE Subject = 'Computers'; Query OK, 0 rows affected (0.46 sec)The above query will create or replace a view ‘Info’. ... Read More

Advertisements