AmitDiwan has Published 10744 Articles

How to correctly implement conditions in MySQL stored procedure?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:42:00

229 Views

To set conditions in stored procedure, use the below syntax −    if yourCondition then    yourStatement1;      else    yourStatement2';       end if ;     end     //Let us implement the above syntax in order to correct missing semicolon in stored procedure −mysql> delimiter ... Read More

Check whether a SortedList object contains a specific key in C#?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:40:32

138 Views

To check whether a SortedList object contains a specific key in C#, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       SortedList list = new SortedList ();       list.Add("A", "Books");       list.Add("B", ... Read More

Convert string (varchar) to timestamp format in MySQL?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:37:06

4K+ Views

To convert string to timestamp format, use STR_TO_DATE() along with DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1602    -> (    -> ReportingDate varchar(40)    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1602 ... Read More

MySQL update column to NULL for blank values

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:35:34

3K+ Views

For this, you can use IF() along with UPDATE command. Let us first create a table −mysql> create table DemoTable1601    -> (    -> FirstName varchar(20) ,    -> LastName varchar(20)    -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command ... Read More

How to check whether a List contains the elements that match the specified conditions in C#?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:34:49

444 Views

To check whether a List contains the elements that match the specified conditions in C#, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    private static bool demo(int i) {       return ((i % 3) == 0);    }    public static ... Read More

How to MySQL SELECT by month?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:30:45

441 Views

To select by month, use MONTH() function. Let us first create a table −mysql> create table DemoTable1599    -> (    -> Shippingdate datetime    -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1599 values('2019-10-21'); Query OK, 1 ... Read More

How to get Synchronize access to the Stack in C#?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:30:01

124 Views

To get synchronize access to the Stack, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Stack stack = new Stack();       stack.Push(100);       stack.Push(200);       stack.Push(300);       ... Read More

Using UNIQUE for varchar columns with some conditions in MySQL?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:28:14

209 Views

For this, you can use UNIQUE constraint on one or more columns −alter table yourTablleName add unique(yourColumnName1, yourColumnName2, ...N);Let us first create a table −mysql> create table DemoTable1598    -> (    -> EmployeeId int,    -> EmployeeName varchar(20),    -> EmployeeCountryName varchar(20)    -> ); Query OK, 0 rows ... Read More

Fix ERROR 1093 (HY000): You can't specify target table for update in FROM clause while deleting the lowest value from a MySQL column?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:20:03

1K+ Views

Let us first create a table −mysql> create table DemoTable1597    -> (    -> Marks int    -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1597 values(45); Query OK, 1 row affected (0.21 sec) mysql> insert into ... Read More

Can we use “rank” as column name with MySQL8?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:18:54

3K+ Views

The rank is a MySQL reserved word defined in MySQL version 8.0.2. Therefore, you cannot use rank as a column name. You need to use backticks around the rank.Let us first check the MySQL version we are working on. Here, I am using MySQL version 8.0.12 −mysql> select version(); +-----------+ ... Read More

Advertisements