AmitDiwan has Published 11365 Articles

How to simulate the LIMIT MySQL clause with an Access database?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 06:19:10

540 Views

In Microsoft Access, you can use TOP instead of LIMIT. Let us first create a −Insert some records in the table using insert command −Following is the query to simulate the LIMIT MySQL clause with an Access database −After clicking Run, you will get the desired output −In MySQL, to ... Read More

MySQL query to order records but fix a specific name and display rest of the values (only some) random

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:47:56

54 Views

For this, you can use ORDER BY RAND() with LIMIT. Let us first create a −mysql> create table DemoTable1426    -> (    -> FirstName varchar(20)    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert −mysql> insert into DemoTable1426 values('John'); Query OK, ... Read More

Is it possible to combine 'DISTINCT' and 'COUNT' queries, so that I can see how many times each distinct value appears in a MySQL table column?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:46:46

136 Views

Yes, you can use aggregate function COUNT(*) along with GROUP BY clause. Let us first create a −mysql> create table DemoTable1425    -> (    -> JoiningYear int    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert −mysql> insert into DemoTable1425 values(2000); ... Read More

MySQL query to replace part of string before dot

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:44:55

221 Views

For this, use CONCAT() along with SUBSTRING_INDEX(). Let us first create a −mysql> create table DemoTable1424    -> (    -> Value varchar(60)    -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert −mysql> insert into DemoTable1424 values('567.78483733'); Query OK, 1 row affected ... Read More

Fetch records from comma separated values using MySQL IN()?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:42:44

2K+ Views

Use FIND_IN_SET() instead of MySQL IN(). Let us first create a −mysql> create table DemoTable1423    -> (    -> CountryName varchar(100)    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert −mysql> insert into DemoTable1423 values('AUS, UK'); Query OK, 1 row affected ... Read More

MySQL query to select all data between range of two dates?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:40:07

606 Views

To select all data between range of two dates, use MySQL BETWEEN −select * from yourTableName where yourColumnName between yourDateValue1 and yourDateValue2;Let us first create a −mysql> create table DemoTable1422    -> (    -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> EmployeeName varchar(20),    -> EmployeeJoiningDate date ... Read More

Replace records based on conditions in MySQL?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:36:25

603 Views

To set conditions, use MySQL CASE statement. Let us first create a −mysql> create table DemoTable1481    -> (    -> PlayerScore int    -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert −mysql> insert into DemoTable1481 values(454); Query OK, 1 row affected ... Read More

Can we fetch multiple values with MySQL WHERE Clause?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:34:46

155 Views

Yes, we can fetch, but use MySQL OR for conditions. Let us first create a −mysql> create table DemoTable1421    -> (    -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> EmployeeName varchar(20),    -> EmployeeSalary int    -> ); Query OK, 0 rows affected (0.82 sec)Insert some ... Read More

How to update multiple rows using single WHERE clause in MySQL?

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:32:00

810 Views

For this, you can use MySQL IN(). Let us first create a −mysql> create table DemoTable1420    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FirstName varchar(20),    -> LastName varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (1.12 sec)Insert ... Read More

Convert MySQL time from HH:MM:SS to HH:MM

AmitDiwan

AmitDiwan

Updated on 12-Nov-2019 05:28:50

751 Views

To convert, use MySQL TIME_FORMAT(). Let us first create a −mysql> create table DemoTable1419    -> (    -> ArrivalTime time    -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. Here, we have inserted time records −mysql> insert into DemoTable1419 values('12:30:45'); ... Read More

Advertisements