Kumar Varma has Published 110 Articles

Query MySQL with unicode char code?

Kumar Varma

Kumar Varma

Updated on 30-Jun-2020 13:33:31

299 Views

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

How to get total occurrences of a value within its own MySQL query?

Kumar Varma

Kumar Varma

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

123 Views

For this, you can use subquery. Let us first create a table −mysql> create table DemoTable    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(20); Query OK, 1 row ... Read More

How to remove all instances of a specific character from a column in MySQL?

Kumar Varma

Kumar Varma

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

779 Views

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

Select all rows except from today in MySQL?

Kumar Varma

Kumar Varma

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

359 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(100),    -> DueDate datetime    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command. Let’s say the current date is “2019-07-03” −mysql> insert into DemoTable ... Read More

Can I get the count of repeated values in a column with MySQL?

Kumar Varma

Kumar Varma

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

882 Views

Yes, you can use ORDER BY DESC with GROUP BY. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> PostMessage varchar(100)    -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the ... Read More

How to use if clause in MySQL to display Students result as Pass or Fail in a new column?

Kumar Varma

Kumar Varma

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

1K+ Views

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

Select the topmost record from a table ordered by desc on the basis of ID?

Kumar Varma

Kumar Varma

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

28 Views

For this, use ORDER BY DESC with LIMIT 1. Let us first create table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserName varchar(100),    -> UserMessage text    -> ); Query OK, 0 rows affected (1.17 sec)Insert some records ... Read More

Can we compare numbers in a MySQL varchar field?

Kumar Varma

Kumar Varma

Updated on 30-Jun-2020 13:07:42

863 Views

Yes, we can do this by first using CAST(). Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentScore varchar(100)    -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table ... Read More

MySQL query to remove a value with only numbers in a column

Kumar Varma

Kumar Varma

Updated on 30-Jun-2020 13:05:28

668 Views

For this, you can use REGEXP. Let us first create a table −mysql> create table DemoTable    -> (    -> ClientCode varchar(100)    -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris902'); Query OK, 1 row ... Read More

How to convert string to time in MySQL?

Kumar Varma

Kumar Varma

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

2K+ Views

You can use format specifier. Following is the syntax −select str_to_date(yourColumnName, '%d/%m/%Y %h:%i %p') as anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable    -> (    -> DueDate varchar(100)    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using ... Read More

1 2 3 4 5 ... 11 Next
Advertisements