MySQL Return Value for Unassigned User Variable

mkotla
Updated on 20-Jun-2020 10:49:23

109 Views

In case, when we refer a user variable which is not assigned any value explicitly, MySQL would return NULL. In other words, its value would be NULL. Following example would illustrate it −mysql> Select @X, @Y, @Z, @S, @G; +------+-------+----------+------+------+ | @X   | @Y    | @Z       | @S   | @G   | +------+-------+----------+------+------+ | Ram  | Shyam | Students | 5000 | NULL | +------+-------+----------+------+------+ 1 row in set (0.00 sec)We can see from the above result set that @X, @Y, @Z and @S has been assigned values explicitly and they returned the values ... Read More

Capture Multiple Matches in the Same Line using Java Regex

Arnab Chakraborty
Updated on 20-Jun-2020 10:49:20

3K+ Views

Exampleimport java.util.regex.*; class PatternMatcher {    public static void main(String args[]) {       int count = 0;       // String to be scanned to find the pattern.       String content = "aaa bb aaa";       String string = "aaa";       // Create a Pattern object       Pattern p = Pattern.compile(string);       // get a matcher object       Matcher m = p.matcher(content);       while(m.find()) {          count++;          System.out.println("Match no:"+count);         ... Read More

Assign Value to MySQL User Variable from Multiple Rows

Srinivas Gorla
Updated on 20-Jun-2020 10:48:56

252 Views

In case, if we will assign a value to a user variable using a statement that returns multiple rows then the value from the last row would be saved in that user variable because user variables can save the only single value. Following the example, in which we are using data from table ‘Tender’, will exhibit it −Examplemysql> select * from Tender; +----+---------------+--------------+ | Sr | CompanyName   | Tender_value | +----+---------------+--------------+ | 1  | Abc Corp.     |   250.369003 | | 2  | Khaitan Corp. |   265.588989 | | 3  | Singla group. |   220.255997 ... Read More

Find Number of Dimensions of an Array in C#

Samual Sam
Updated on 20-Jun-2020 10:48:43

945 Views

To find the number of dimensions of an array, use the Rank property.arr.RankHere, arr is our array −int[, ] arr = new int[3, 4];If you also want to get the rows and columns it has, then use the GetLength property −arr.GetLength(0); arr.GetLength(1);The following is the complete code −Example Live Demousing System; class Program {    static void Main() {       int[, ] arr = new int[3, 4];       Console.WriteLine(arr.GetLength(0));       Console.WriteLine(arr.GetLength(1));       // Length       Console.WriteLine(arr.Length);       Console.WriteLine("Upper Bound: {0}", arr.GetUpperBound(0).ToString());       Console.WriteLine("Lower Bound: ... Read More

Use SET Statement to Assign SELECT Result to MySQL User Variable

radhakrishna
Updated on 20-Jun-2020 10:48:08

607 Views

For using the SET statement to assign a SELECT result to a user variable we need to write the SELECT statement as a subquery within parentheses. The condition is that the SELECT statement must have to return a single value. To make it understand we are using the data from ‘Tender’ table which is as follows −mysql> select * from Tender; +----+---------------+--------------+ | Sr | CompanyName   | Tender_value | +----+---------------+--------------+ | 1  | Abc Corp.     | 250.369003   | | 2  | Khaitan Corp. | 265.588989   | | 3  | Singla group. | 220.255997   | ... Read More

Find Length of an Array in C#

George John
Updated on 20-Jun-2020 10:48:01

18K+ Views

To find the length of an array, use the Array.Length() method.ExampleLet us see an example − Live Demousing System; class Program {    static void Main(){       int[] arr = new int[10];       // finding length       int arrLength = arr.Length;       Console.WriteLine("Length of the array: "+arrLength);    } }OutputLength of the array: 10Above, we have an array −int[] arr = new int[10];Now to find the length, we used the Length() method −int arrLength = arr.Length;

Capacity Property of ArrayList Class in C#

karthikeya Boyini
Updated on 20-Jun-2020 10:47:28

3K+ Views

The capacity property in ArrayList class gets or sets the number of elements that the ArrayList can contain.Capacity is always greater than count. For capacity property −arrList.CapacityThe default capacity is 4. If 5 elements are there, then its capacity is doubled and would be 8. This goes on.You can try to run the following the code to implement Capacity property in C#. This also shows what we discussed above −Example Live Demousing System; using System.Collections; class Demo {    public static void Main() {       ArrayList arrList = new ArrayList();       arrList.Add(19);       arrList.Add(44); ... Read More

Count Property of ArrayList Class in C#

Samual Sam
Updated on 20-Jun-2020 10:46:48

291 Views

The Count property in the ArrayList class counts the number of elements in the ArrayList.Firstly, add elements to the ArrayList −ArrayList arrList = new ArrayList(); arrList.Add(98); arrList.Add(55); arrList.Add(65); arrList.Add(34);Then get the count of the array list −arrList.CountThe following is the code to implement Count property in C# −Example Live Demousing System; using System.Collections; class Demo {    public static void Main() {       ArrayList arrList = new ArrayList();       arrList.Add(98);       arrList.Add(55);       arrList.Add(65);       arrList.Add(34);       Console.WriteLine("Count = " + arrList.Count);    } }OutputCount = 4

Use Prepared Statements in MySQL

Nikitha N
Updated on 20-Jun-2020 10:45:58

593 Views

MySQL server supports prepared statements, which are useful when we want to run many queries that differ only in very small details. We can prepare a statement and then execute it multiple times and each time with different data values. Basically, prepared statements in MySQL take advantage of client/server binary protocol. Prepared statements provide enhanced performance because the complete statement is parsed only one by the server.Followings are the steps for using prepared statements in MySQL −Prepare the statement It is the first step in which we will prepare a statement by using PREPARE statement. For example, following is a statement ... Read More

Capacity Property of SortedList Class in C#

Ankith Reddy
Updated on 20-Jun-2020 10:45:43

344 Views

The capacity property in SortedList class has the maximum size of the SortedList.The default capacity of a SortedList is 16.You can try to run the following the code to implement Capacity property of SortedList class in C# −Example Live Demousing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {          SortedList s = new SortedList();          s.Add("S1", "Maths");          s.Add("S2", "Science");          s.Add("S3", "English");          s.Add("S4", "Economics");          Console.WriteLine("Capacity = " ... Read More

Advertisements