Kumar Varma has Published 110 Articles

Display records with more than two occurrences in MySQL?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

571 Views

For this, you can use GROUP BY HAVING clause. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Subject varchar(100)    -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table ... Read More

MySQL query to select a count on two separate conditions?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

170 Views

Use CASE statement for this. Let us first create a table −mysql> create table DemoTable    -> (    -> StudentMarks int,    -> isValid tinyint(1)    -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(45, 0); ... Read More

How to SELECT fields from one table and INSERT to another in MySQL?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

137 Views

Let us first create a table −mysql> create table DemoTable1    -> (    -> StudentId int,    -> StudentName varchar(20)    -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10, 'John'); Query OK, 1 row affected ... Read More

How to add a column using MySQL SELECT in an already created table?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

206 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100),    -> Age int    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to add some days to str_to_date() MySQL function?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

96 Views

You can use DATE_ADD() function from MySQL. Let us first create a table −mysql> create table DemoTable    -> (    -> ShippingDate varchar(100)    -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('06-01-2019'); Query OK, 1 ... Read More

How to calculate the difference between time in different MySQL columns?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

172 Views

You can use TIME_FORMAT(). Let us first create a table −mysql> create table DemoTable    -> (    -> PunchIn time,    -> PunchOut time,    -> Launch time    -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

How to show GRANTS for root in MySQL?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

84 Views

For this, use the following syntax, wherein we have used SHOW GRANTS −SHOW GRANTS FOR 'yourUserName'@'yourHostName';HostName may be ‘%’ or localhost.Let us implement the above syntax in order to show grants from ROOT −mysql> SHOW GRANTS FOR 'root'@'%' ;Output+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@%               ... Read More

Update multiple columns of a single row MySQL?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

436 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> FirstName varchar(100),    -> Age int,    -> Score int    -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Robert', 21, 78); ... Read More

Getting the maximum value from a varchar field in MySQL

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

135 Views

Use MAX() function along with SUBSTRING() for this. Let us first create a table −mysql> create table DemoTable    -> (    -> Id varchar(200)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-0515-1980'); Query OK, ... Read More

How to detect a long press in iOS?

Kumar Varma

Kumar Varma

Updated on 30-Jul-2019 22:30:26

707 Views

Long-press (also known as press-and-hold) gestures detect one or more fingers touching the screen for an extended period of time. You configure the minimum duration required to recognize the press and the number of times the fingers must be touching the screen. (The gesture recognizer is triggered only by the ... Read More

Advertisements