Check Column Values for Strings or Digits in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:22:19

1K+ Views

If you want only the string values, then use the below syntax −select *from yourTableName where yourColumnName NOT regexp '^[0-9]+$';If you want only the digit, then use the below syntax −select *from yourTableName where yourColumnName regexp '^[0-9]+$';Let us first create a table −mysql> create table DemoTable(    Id varchar(100) ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('1000'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Carol_Smith'); Query OK, 1 row affected (0.15 ... Read More

Bellman-Ford Algorithm in C++

sudhir sharma
Updated on 04-Oct-2019 07:21:19

4K+ Views

Bellman Ford Algorithm is dynamic programming algorithm which is used to find the shortest path of any vertex computed from a vertex treated as starting vertex. this algorithm follows iterative method and continuously tries to find shortest Path. The Bellman Ford Algorithm on weighted graph.this algorithm was proposed by Alphonso shimbel in 1955. The algorithm has revisions by Richard Bellman and Lester Ford in the year 1956 and 1958, due to this algorithm was named Bellman Ford Algorithm. This algorithm was also revised by Eward F. Moore in 1957, which made its name to Bellman-Ford-Moore Algorithm.This algorithm is better as ... Read More

Insert Multiple Values in a Temporary Table with a Single MySQL Query

AmitDiwan
Updated on 04-Oct-2019 07:19:24

799 Views

Let us first create a table −mysql> create temporary table DemoTable (    SerialNumber int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command. Here, we are inserting multiple values in a temporary table −mysql> insert into DemoTable values(1),(2),(3),(4),(5),(6),(7),(8); Query OK, 8 rows affected (0.00 sec) Records: 8 Duplicates: 0 Warnings: 0Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------------+ | SerialNumber | +--------------+ |            1 | |            2 | |            3 | |            4 | |            5 | |            6 | | 7 | | 8 | +--------------+ 8 rows in set (0.00 sec)

Check Column Values in MySQL and Set Records in a Single Row

AmitDiwan
Updated on 04-Oct-2019 07:17:25

76 Views

For this, you can use GROUP_CONCAT() along with DISTINCT. Let us first create a table −mysql> create table DemoTable (    Id int,    Subject varchar(40) ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'MySQL'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(100, 'MongoDB'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(100, 'Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(100, 'MongoDB'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(101, 'MySQL'); ... Read More

MySQL Query to Display Records Containing a Single Word

AmitDiwan
Updated on 04-Oct-2019 07:15:37

318 Views

For this, you can filter records on the basis of LIKE. Let us first create a table −mysql> create table DemoTable (    Name varchar(50) ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Adam Smith'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 ... Read More

Sort Increasing the Difference Between N and Table Values in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:14:12

75 Views

For sort by distance, use ORDER BY ABS(). Let us first create a table −mysql> create table DemoTable (    Number int ); Query OK, 0 rows affected (1.16 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.51 sec) mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(102); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable values(103); Query OK, 1 row affected (0.84 sec) mysql> insert into DemoTable values(104); Query OK, 1 row affected (0.17 sec) mysql> insert ... Read More

Fetch Date Record That Equals Today in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:12:11

146 Views

For this, compare the date records with the current date using the CURDATE() method. Let us first create a table −mysql> create table DemoTable (    RegistrationLastDate datetime ); Query OK, 0 rows affected (0.61 sec)Let’s say the current date is −2019-09-03Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-08-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-09-03 9:50:56'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('2019-09-03'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-09-02'); Query OK, 1 row affected (0.18 sec) mysql> ... Read More

Array Sum After Dividing Numbers from Previous in C

sudhir sharma
Updated on 04-Oct-2019 07:11:11

252 Views

Array is a sequence of elements of same data type. in this problem we are going to consider integer array for solving the problem. in this problem we are going to find sum of Elements found by dividing the element from the element proceeding it.Let’s take a few examples to understand this Problem better −Example 1 −Array : 3 , 5 ,98, 345 Sum : 26Explanation − 3 + 5/3 + 98/5 + 345/98 = 3 + 1 + 19 + 3 = 26We have divided each element with its preceding element and considered only integer parts of the divisions ... Read More

Order By Case to Display Special Character in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:10:00

611 Views

Let us first create a table −mysql> create table DemoTable (    StudentId varchar(40) ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('10'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('~'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('40'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected ... Read More

Interesting Facts About C++ Bitset

sudhir sharma
Updated on 04-Oct-2019 07:08:49

302 Views

C++ programming language defines a container in c++ standard Template Library named as bitset. This bitset container is used in order to work on elements at the bit level i.e. each bit of the variable the bits i.e. binary conversion of the given value.1. Bitset is like an string − Bitset is a container of bits ( only 0 and 1 are valid ). You can create a bitset with any set of bits specified by start index value of the bitset and the number of elements that are considered i.e. you can create a bitset with 2 elements starting ... Read More

Advertisements