AmitDiwan has Published 10744 Articles

Select Statement to retrieve the same first names with similar last name (but different case) using MySQL?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:17:49

412 Views

Let us first create a table −mysql> create table DemoTable623 (FirstName varchar(100), LastName varchar(100), Age int); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable623 values('John', 'Smith', 23); Query OK, 1 row affected (0.66 sec) mysql> insert into DemoTable623 values('Adam', ... Read More

MySQL query to set different combinations for values in a table?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:15:03

387 Views

Let us first create a table −mysql> create table DemoTable622 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value1 int, Value2 int); Query OK, 0 rows affected (1.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable622(Value1, Value2) values(1000, 1000); Query OK, 1 row affected (0.23 sec) ... Read More

How to group by column name and ensure the query retrieves the last update in MySQL?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:12:30

99 Views

Let us first create a table −mysql> create table DemoTable621 (UserName varchar(100), UserEmailId varchar(100), UserLastPost datetime); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable621 values('John', 'John@gmail.com', '2019-04-10 11:01:10'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable621 ... Read More

Where is MySQL bin directory located in Windows OS?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:00:58

5K+ Views

Let’s say we installed MySQL version is 8.0 on our Windows OS. The bin directory is present at the following location −C:\Program Files\MySQL\MySQL Server 8.0\binLet us check the location. The screenshot is as follows −These are the drives −Go to C: drive and click Program Files −Now, click “MySQL” and ... Read More

MySQL statement to copy data from one table and insert into another table

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 06:42:48

465 Views

For this, you can use INSERT INTO….SELECT statement. Let us first create a table −mysql> create table DemoTabe1 (Marks int); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTabe1 values(68); Query OK, 1 row affected (0.18 sec) mysql> insert into ... Read More

Divide numbers from two columns and display result in a new column with MySQL

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 06:39:15

7K+ Views

Let us first create a table −mysql> create table DemoTable719 (FirstNumber int, SecondNumber int); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable719 values(20, 10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable719 values(500, 50); Query OK, ... Read More

Fetch ordered records after a specific limit in MySQL

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 06:29:34

121 Views

For this, you can use a subquery. Let us first create a table −mysql> create table DemoTable618 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100) ); Query OK, 0 rows affected (1.45 sec)Insert some records in the table using insert command −mysql> insert into DemoTable618(StudentFirstName) values('David'); Query ... Read More

Select the next row after skipping every 2 rows in MySQL

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 06:21:05

416 Views

To skip rows, you can use OFFSET. Let us first create a table −mysql> create table DemoTable617(Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (1.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable617(FirstName) values('John'); Query OK, 1 row affected ... Read More

How to add columns values with suffixed currency sign in MySQL

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 06:15:11

221 Views

For this, you can use aggregate function SUM(). Let us first create a table:mysql> create table DemoTable616 (Price varchar(100)); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable616 values('€200.00'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable616 ... Read More

Delete a specific record on the basis of EmployeeId in MySQL

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 14:11:16

340 Views

Let us first create a table −mysql> create table DemoTable615 (EmployeeId varchar(100), EmployeeName varchar(100)); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable615 values('EMP-101', 'Adam'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable615 values('EMP-1001', 'David'); Query OK, ... Read More

Advertisements