Let’s say the current date is −'2019-10-20We will first see an example and create a table −mysql> create table DemoTable1582 -> ( -> PostedDate datetime -> ); Query OK, 0 rows affected (13.36 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1582 values('2019-01-21 12:34:40'); Query OK, 1 row affected (1.06 sec) mysql> insert into DemoTable1582 values('2019-10-15 11:00:00'); Query OK, 1 row affected (0.87 sec) mysql> insert into DemoTable1582 values('2019-10-25 1:10:00'); Query OK, 1 row affected (1.14 sec)Display all records from the table using select statement −mysql> select * from DemoTable1582;This will produce the ... Read More
To get all elements of a List that match the conditions specified by the predicate, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo { private static bool demo(int i) { return ((i % 3) == 0); } public static void Main(String[] args) { List list = new List(); list.Add(9); list.Add(15); list.Add(20); list.Add(40); list.Add(50); list.Add(60); Console.WriteLine("List elements..."); foreach (int i in list) { ... Read More
To ensure that MySQL rows are unique, you need to use UNIQUE constraint. Let us first create a table −mysql> create table DemoTable1580 -> ( -> id int, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (0.73 sec)Here is the query to create unique constraints to ensure MySQL rows are unique −mysql> alter table DemoTable1580 add unique index(id, Name, Age); Query OK, 0 rows affected (0.45 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable1580 values(101, 'Chris', 21); Query OK, ... Read More
To get hash code for the specified key of a Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class HashCode : Hashtable { public static void Main(string[] args) { HashCode hash = new HashCode(); hash.Add("A", "Jacob"); hash.Add("B", "Mark"); hash.Add("C", "Tom"); hash.Add("D", "Nathan"); hash.Add("E", "Tim"); hash.Add("F", "John"); hash.Add("G", "Gary"); Console.WriteLine("Key and Value pairs..."); foreach(DictionaryEntry entry in hash) { Console.WriteLine("{0} and {1} ", ... Read More
To select the last three rows in ascending order, use ORDER BY DESC LIMIT as in the below syntax −select * from (select * from yourTableName order by yourColumnName desc limit 3) anyAliasName order by yourColumnName ;Let us first create a table −mysql> create table DemoTable1579 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1579(Name) values('Robert'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable1579(Name) values('Bob'); Query OK, 1 ... Read More
To get synchronize access to the ListDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { ListDictionary dict = new ListDictionary(); dict.Add("1", "SUV"); dict.Add("2", "Sedan"); dict.Add("3", "Utility Vehicle"); dict.Add("4", "Compact Car"); dict.Add("5", "SUV"); dict.Add("6", "Sedan"); dict.Add("7", "Utility Vehicle"); dict.Add("8", "Compact Car"); dict.Add("9", "Crossover"); dict.Add("10", "Electric Car"); Console.WriteLine("ListDictionary elements..."); ... Read More
Here is the query to create first table.mysql> create table DemoTable1 -> ( -> StudentName varchar(20), -> StudentMarks int -> ); Query OK, 0 rows affected (0.67 sec)To understand the above concept, let us create second table.mysql> create table DemoTable2 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2 values('Chris'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable2;This will produce the following output −+-------+ ... Read More
The easiest way to get number of rows, use aggregate function COUNT(*). Let us first create a table −mysql> create table DemoTable1575 -> ( -> FirstName varchar(20) -> ); Query OK, 0 rows affected (1.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1575 values('Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1575 values('Bob'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1575 values('Adam'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1575 values('Robert'); Query OK, 1 row affected (0.15 sec)Display all records from the table ... Read More
Let us first create a table −mysql> create table DemoTable1574 -> ( -> StudentCode varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1574 values('111_Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1574 values('______'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable1574 values('David_12345'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1574 values('______'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable1574;This will produce the following ... Read More
To retrieve table names from a database in MySQL, the syntax is as follows −show tables from yourDatabaseName;Let us implement the above query in order to retrieve table names from a database in MySQL −mysql> show tables from hb_student_tracker;This will produce the following output −+------------------------------+ | Tables_in_hb_student_tracker | +------------------------------+ | demotable192 | | demotable193 | | demotable194 | | demotable195 | | demotable196 ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP