Rama Giri has Published 122 Articles

Get the number of rows in a particular table with MySQL

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:30:38

Let us first create a table −mysql> create table DemoTable    -> (    -> LastName varchar(100)    -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert ... Read More

How to create and fill a new column in an already created MySQL table?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:27:16

Let us first create a table −mysql> create table DemoTable    -> (    -> Value1 int,    -> Value2 int    -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 10); Query OK, 1 row affected ... Read More

MySQL query to find a value appearing more than once?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:20:19

Let us first create a table −mysql> create table DemoTable    -> (    -> value int    -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.19 sec) mysql> insert ... Read More

How to select return value from MySQL prepared statement?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:17:20

Let us create a stored procedure and select return value from MySQL prepared statement −mysql> DELIMITER // mysql> CREATE PROCEDURE return_value()    -> BEGIN    ->   SET @returnQuery= 'SELECT 98 INTO @value';    ->   PREPARE stmt FROM @returnQuery;    ->   EXECUTE stmt;    -> END    -> ... Read More

How to count number of NULLs in a row with MySQL?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:15:04

Use ISNULL() from MySQL. Let us first create a table −mysql> create table DemoTable    -> (    -> Number1 int,    -> Number2 int    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, NULL); Query ... Read More

Display records ignoring NULL in MySQL

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:11:10

Use IS NOT NULL to display only NOT NULL records. Let us first create a table −mysql> create table DemoTable    -> (    -> FirstName varchar(100)    -> ); Query OK, 0 rows affected (3.01 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); ... Read More

How to get the seed value of an identity column in MySQL?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:09:13

For this, you can use SHOW VARIABLES command −mysql> SHOW VARIABLES LIKE 'auto_inc%';OutputThis will produce the following output −+--------------------------+-------+ | Variable_name            | Value | +--------------------------+-------+ | auto_increment_increment | 1     | | auto_increment_offset    | 1     | +--------------------------+-------+ 2 rows in set ... Read More

MySQL select for exact case sensitive match with hyphen in records

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:06:30

For exact case sensitive match, use BINARY after WHERE clause in MySQL. Let us first create a table −mysql> create table DemoTable    -> (    -> EmployeeCode varchar(100)    -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Use MySQL LIKE and NOT LIKE to display similar results?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:03:26

Let us first create a table −mysql> create table DemoTable    -> (    -> CollegeCode varchar(100)    -> ); Query OK,  0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Col.1995.01.21'); Query OK,  1 row affected (0.10 sec) mysql> insert into DemoTable values('Col.2016.11.22'); Query OK,  1 row affected (0.20 sec) mysql> insert into DemoTable values(null); Query OK,  1 row affected (0.14 sec) mysql> insert into DemoTable values('Col.2018.12.01'); Query OK,  1 row affected (0.22 sec) mysql> insert into DemoTable values('Col.2019.03.12'); Query OK,  1 row affected (0.15 sec)Display all ... Read More

How to Order by a specific string in MySQL?

Rama Giri

Rama Giri

Updated on 30-Jun-2020 13:00:16

Let us first create a table −mysql> create table DemoTable    -> (    -> FirstName varchar(100)    -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.13 sec) mysql> insert ... Read More

1 2 3 4 5 ... 13 Next
Advertisements