AmitDiwan has Published 10744 Articles

MySQL RegExp to fetch records with only a specific number of words

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:17:13

189 Views

For this, use Regular Expression in MySQL as in the below syntax −select * from yourTableName where yourColumnName regexp '\land[\land ]+[ ]+[\land ]+$';The above query will work when the two words are separated by a space. Let us first create a table −mysql> create table DemoTable1412    -> (   ... Read More

Call Stored Procedures within a Stored Procedure with IF Logic?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:16:09

675 Views

To call stored procedures within a stored procedure, the syntax is as follows −If yourInputValue > 100 then      call yourProcedureName1();  else     call yourProcedureName2();     end If ;     ENDLet us implement the above syntax. In order to implement the above concept, let us create ... Read More

Get the specified members of the current Type in C#?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:15:22

110 Views

To get the specified members of the current Type, the code is as follows −Example Live Demousing System; using System.Reflection; public class Demo {    public static void Main() {       Type type = typeof(Subject);       try {          FieldInfo fieldInfo = type.GetField("SubName");   ... Read More

Use MySQL REGEXP to ignore number and get only String and '/'

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:13:57

437 Views

For this, use REGEXP_REPLACE(). Let us first create a table −mysql> create table DemoTable1595    -> (    -> StudentCode varchar(50)    -> ); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1595 values('200 John'); Query OK, 1 row affected ... Read More

Select nth highest value in MySQL

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:12:56

306 Views

To select the nth highest value in MySQL, following is the syntax −select distinct(yourColumnName) from yourTableName order by yourColumnName DESC limit (NthValue-1), 1;Let us first create a table −mysql> create table DemoTable1594    -> (    -> Marks int    -> ); Query OK, 0 rows affected (0.49 sec)Insert some ... Read More

Create a Queue from another collection in C#?

AmitDiwan

AmitDiwan

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

95 Views

To create a Queue from another collection, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       Queue queue = new Queue();       queue.Enqueue("One");       queue.Enqueue("Two");       queue.Enqueue("Three");       ... Read More

Alternative to MySQL CASE WHEN in MySQL

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 07:04:51

699 Views

Use IF() method as an alternative to CASE WHEN in MySQL. Let us first create a table −mysql> create table DemoTable1593    -> (    -> PlayerScore int    -> ); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1593 ... Read More

Count the total number of elements in the List in C#?

AmitDiwan

AmitDiwan

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

610 Views

To count the total number of elements in 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("One");       list.Add("Two");       ... Read More

Only update the MySQL field if the field contains null or 0?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 06:52:29

253 Views

For this, set conditions using MySQL IF(). Let us first create a table −mysql> create table DemoTable1592    -> (    -> StudentMarks int    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1592 values(56); Query OK, 1 ... Read More

How to convert varchar “time” to real time in MySQL?

AmitDiwan

AmitDiwan

Updated on 16-Dec-2019 06:51:20

476 Views

For this, you can use TIME_FORMAT(). Let us first create a table −mysql> create table DemoTable1591    -> (    -> ArrivalTime varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1591 values('1620'); Query OK, 1 row ... Read More

Advertisements