Return Fields Appearing a Certain Number of Times Using MySQL DISTINCT

AmitDiwan
Updated on 11-Dec-2019 05:49:49

108 Views

To return fields appearing a certain number of times, the syntax is as follows −select distinct yourColumnName, count(yourColumnName) from yourTableName where yourColumnName LIKE 'J%' group by yourColumnName having count(*) > 1 order by yourColumnName;Let us first create a table −mysql> create table DemoTable1500    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −Mysql> insert into DemoTable1500 values(‘Adam’); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1500 values('John'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1500 values('Mike'); Query OK, 1 ... Read More

Check if HybridDictionary is Synchronized in C#

AmitDiwan
Updated on 11-Dec-2019 05:49:05

142 Views

To check if HybridDictionary is synchronized, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary dict1 = new HybridDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("HybridDictionary1 elements...");       foreach(DictionaryEntry d in dict1){          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("Is the HybridDictionary1 having ... Read More

Check Input, Output, and Error Redirection in C#

AmitDiwan
Updated on 11-Dec-2019 05:45:53

259 Views

To check if the input is redirected on the Console or not, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("Input Redirected? = "+Console.IsInputRedirected);    } }OutputThis will produce the following output −Input Redirected? = FalseExampleTo check if the output is redirected on the Console or not, the code is as follows − Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("Output Redirected? = "+Console.IsInputRedirected);    } }OutputThis will produce the following output −Output Redirected? = FalseExampleTo check if the error is ... Read More

Duplicate a MySQL Database Without Using mysqldump

AmitDiwan
Updated on 11-Dec-2019 05:44:21

819 Views

To duplicate a MySQL database, the syntax is as follows −create table yourdatabaseName1.yourTableName1 select * from yourdatabaseName2.yourTableName2;Let us first create a table −mysql> use sample; Database changed mysql> create table DemoTable101    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (1.45 sec)Insert some records in the table using insert command−mysql> insert into DemoTable101 values(101, 'Sam'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable101 values(102, 'Bob'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable101 values(103, 'David'); Query OK, 1 row affected (0.11 sec)Display all records ... Read More

Check Caps Lock and Num Lock Status in C# Console

AmitDiwan
Updated on 11-Dec-2019 05:43:22

395 Views

To check if Caps Lock is on or off through Console, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("The CAPS LOCK is on or not? "+ Console.CapsLock);    } }OutputThis will produce the following output −The CAPS LOCK is on or not? FalseExampleTo check if Num Lock is on or off through Console, the code is as follows − Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("The Num LOCK is on or not? "+ Console.NumberLock);    } }OutputThis will produce ... Read More

Use MySQL LIKE Query to Search Column Value

AmitDiwan
Updated on 11-Dec-2019 05:41:59

939 Views

To search a column value with %, the syntax is as follows −select * from yourTableName  where yourColumnName LIKE '\%%';Let us first create a table −mysql> create table DemoTable1497    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert −mysql> insert into DemoTable1497 values('%JohnSmith'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1497 values('DavidMiller'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1497 values('CarolTaylor%'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1497 values('%DavidMiller'); Query OK, 1 row affected (0.12 ... Read More

Group Results by Date and Count Duplicate Values in MySQL

AmitDiwan
Updated on 11-Dec-2019 05:40:38

595 Views

Let us first create a table −mysql> create table DemoTable1496    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> PassengerCode varchar(20),    -> ArrivalDate datetime    -> ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('202', '2013-03-12 10:12:34'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('202_John', '2013-03-12 11:00:00'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('204', '2013-03-12 10:12:34'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('208', '2013-03-14 ... Read More

Get Two Days Data from MySQL Table with Timestamp Values

AmitDiwan
Updated on 11-Dec-2019 05:38:29

356 Views

Let us first create a table −mysql> create table DemoTable1495    -> (    -> ShippingDate bigint    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1495 values(1570127400); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1495 values(1570213800); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1495 values(1570645800); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1495 values(1570300200); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select * from DemoTable1495;This will produce the following ... Read More

Retrieve System's Reference to Specified String in C#

AmitDiwan
Updated on 11-Dec-2019 05:37:40

111 Views

To retrieve the system’s reference to the specified String, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       string str1 = "David";       string str2 = string.Intern(str1);       Console.WriteLine("String1 = "+str1);       Console.WriteLine("System reference of String1 = "+str2);    } }OutputThis will produce the following output −String1 = David System reference of String1 = DavidExampleLet us now see another example − Live Demousing System; public class Demo{    public static void Main(string[] args){       string str1 = "50";       ... Read More

Remove Element from Specified Index of List in C#

AmitDiwan
Updated on 11-Dec-2019 05:33:07

290 Views

To remove the element from the specified index of the List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       List list = new List();       list.Add("Ryan");       list.Add("Kevin");       list.Add("Andre");       list.Add("Tom");       list.Add("Fred");       list.Add("Jason");       list.Add("Jacob");       list.Add("David");       Console.WriteLine("Count of elements in the List = "+list.Count);       Console.WriteLine("Enumerator iterates through the list elements...");       List.Enumerator demoEnum = list.GetEnumerator();     ... Read More

Advertisements