AmitDiwan has Published 10740 Articles

How to update a MySQL date type column?

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:59:19

423 Views

Let us first create a table −mysql> create table DemoTable1451    -> (    -> JoiningDate date    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1451 values('2019-07-21'); Query OK, 1 row affected (0.07 sec) mysql> insert into ... Read More

Get or Set at specified index in StringCollection in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:58:23

176 Views

To get or set at specified index in StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection strCol = new StringCollection();       String[] strArr = new String[] { "A", "B", "C", "D", ... Read More

Display matching repeated date records only once in MySQL

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:56:12

174 Views

Let’s say we are finding records matching with the current date. Since we want repeated matching records only once, use LIMIT.For example, the current date is −2019-10-02Let us first create a table −mysql> create table DemoTable1450    -> (    -> DueDate date    -> ); Query OK, 0 rows ... Read More

Check if SortedSet and a specified collection share common elements in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:55:19

126 Views

To check if SortedSet and a specified collection share common element, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       SortedSet set1 = new SortedSet();       set1.Add(100);       set1.Add(200);       ... Read More

Return maximum value from records in MySQL

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:53:12

199 Views

Let us first create a table −mysql> create table DemoTable1449    -> (    -> PlayerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> PlayerScore int    -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1449(PlayerScore) values(1040); Query ... Read More

Check if the current date falls in a given date range using MySQL query

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:50:53

882 Views

Let us first create a table −mysql> create table DemoTable1448    -> (    -> StartDate date,    -> EndDate date    -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1448 values('2019-01-21', '2019-03-22'); Query OK, 1 row affected ... Read More

MySQL db query to fetch records from comma separate values on the basis of a specific value

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:47:04

191 Views

For this, you can use REGEXP in MySQL. Let’s say you want the row records wherein any of the comma separated value is 90. For this, use regular expression.Let us first create a table −mysql> create table DemoTable1447    -> (    -> Value varchar(100)    -> ); Query OK, ... Read More

Find the difference between current date and the date records from a MySQL table

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:44:06

360 Views

To find the difference, use the DATEDIFF() method. Let us first create a table −mysql> create table DemoTable1446    -> (    -> DueDate date    -> ); Query OK, 0 rows affected (1.42 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1446 values('2019-01-21'); Query OK, ... Read More

Set conditions in a MySQL stored procedure

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:40:40

768 Views

To set conditions in a stored procedure, use IF...ELSE in MySQL. Following is the syntax for if-else −IF yourCondition then       yourStatement1,  ELSE           yourStatement2,  END IF;Let us implement the above syntax in a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE IF_ELSE_DEMO(IN value ... Read More

How to get string as date in MySQL with dates as dot format specifier?

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 05:33:38

461 Views

To get string as date, use STR_TO_DATE() method. Let us first create a table −mysql> create table DemoTable1445    -> (    -> AdmissionDate varchar(20)    -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1445 values('01.10.2019'); Query OK, ... Read More

Advertisements