Specify Sort Order Using Non-Retrieved Column in MySQL

Prabhas
Updated on 22-Jun-2020 11:02:44

130 Views

Actually, as we know that we can specify a sort order with the help of the ORDER BY clause. We need to write the ORDER BY keyword followed by the name of the column on which we want to sort the table. It is not necessary that we have to use that column name after the SELECT keyword in the query.Examplemysql> Select Sr, Item from ratelist ORDER BY Price; +----+------+ | Sr | Item | +----+------+ |  5 | T    | |  1 | A    | |  2 | B    | |  4 | h    | ... Read More

Convert Array of Characters into String in C#

Arjun Thakur
Updated on 22-Jun-2020 11:01:48

239 Views

Let us first set an array of 5 characters −char[] ch = new char[15]; ch[0] = 'T'; ch[1] = 'r'; ch[2] = 'i'; ch[3] = 'c'; ch[4] = 'k';Now convert them into a string −string str = new string(ch);Here is the complete code −ExampleUsing System; class Program {    static void Main() {       char[] ch = new char[15];       ch[0] = 'T';       ch[1] = 'r';       ch[2] = 'i';       ch[3] = 'c';       ch[4] = 'k';       // converting to string       string str = new string(ch);       Console.WriteLine(str);    } }

Specify Number of Records in MySQL Output

Abhinanda Shri
Updated on 22-Jun-2020 11:01:04

227 Views

We can specify the number of records to be returned in output by adding a LIMIT clause in MySQL query. LIMIT clause restricts the number of rows to be returned. Consider the following example −mysql> Select * from ratelist ORDER BY Price; +----+------+-------+ | Sr | Item | Price | +----+------+-------+ |  5 | T    |   250 | |  1 | A    |   502 | |  2 | B    |   630 | |  4 | h    |   850 | |  3 | C    |  1005 | +----+------+-------+ 5 rows in set ... Read More

Convert String to Int in C#

George John
Updated on 22-Jun-2020 11:00:34

415 Views

Let’s say our string is −string str ="9999";Now, use the Int32.Parse() to convert the string into integer −int n = Int32.Parse(str);Now display the integer value as shown in the following code −Exampleusing System; class Demo {    static void Main() {       string str ="9999";       int n = Int32.Parse(str);       Console.WriteLine(n);    } }

Cancel MySQL Command in Progress

Giri Raju
Updated on 22-Jun-2020 10:59:45

155 Views

Suppose if we do not want to execute a command that we are entering, then we can use a clear \c option which clears the current input. For example, the use of \c option can be done as follows −mysql> Select *     -> from\cIn the example above, when we use \c in a statement, MySQL clears the current input and returns back to the MySQL prompt for accepting other statements.

Convert Subqueries to INNER JOIN

Samual Sam
Updated on 22-Jun-2020 10:59:14

1K+ Views

To make it understand we are using the data from the following tables −mysql> Select * from customers; +-------------+----------+ | Customer_Id | Name     | +-------------+----------+ |           1 | Rahul    | |           2 | Yashpal  | |           3 | Gaurav   | |           4 | Virender | +-------------+----------+ 4 rows in set (0.00 sec) mysql> Select * from reserve; +------+------------+ | ID   | Day        | +------+------------+ |    1 | 2017-12-30 | | ... Read More

CSS Descendant Selector

varun
Updated on 22-Jun-2020 10:58:36

373 Views

The descendant selector in CSS is used to match all elements that are descendants of a specified element.ExampleYou can try to run the following code to implement CSS Descendent Selector:Live Demo                    div p {             background-color: orange;          }                              Para 1 in the div          Para 2 in the div             Para 3 outside the div.     Output

Flow Control in Try-Catch-Finally in C#

karthikeya Boyini
Updated on 22-Jun-2020 10:58:29

763 Views

The flow control in try, catch, and finally can be understood using the following example. Here, we are dividing two numbers −Example Live Demousing System; namespace ErrorHandlingApplication {    class DivNumbers {       int result;       DivNumbers() {          result = 0;       }       public void division(int num1, int num2) {          try {             result = num1 / num2;          } catch (DivideByZeroException e) {             Console.WriteLine("Exception caught: {0}", e);   ... Read More

Output of NULL Value in Arithmetic Expression

mkotla
Updated on 22-Jun-2020 10:58:08

1K+ Views

As we know that a NULL is no value and it is not the same as zero. MySQL represents a database column as NULL if it does not contain any data. Now, if we will use NULL in any arithmetic expression then the result will be NULL also.Examplemysql> Select 65/NULL, 65+NULL, 65*NULL, 65-NULL, 65%NULL; +---------+---------+---------+---------+---------+ | 65/NULL | 65+NULL | 65*NULL | 65-NULL | 65%NULL | +---------+---------+---------+---------+---------+ |    NULL |    NULL |    NULL |    NULL |    NULL | +---------+---------+---------+---------+---------+ 1 row in set (0.00 sec)From the above example, it can be observed that if we ... Read More

Different MySQL Prompts on the Command Line

Sravani S
Updated on 22-Jun-2020 10:57:40

459 Views

As we know that after writing the first line of multiple-line queries, MySQL changes the prompt. The following table shows different MySQL prompts and it's meaning −PromptMeaning         mysql>It means MySQL is ready for a new command. →It means that MySQL is waiting for the next line of multiple-line command. ‘>It means that MySQL is waiting for the next line, waiting for the completion of a string that began with a single quote. “>It means that MySQL is waiting for the next line, waiting for the completion of a string that began with a double quote. `>It means that MySQL is waiting ... Read More

Advertisements