George John has Published 1081 Articles

How to cut only the first character in MySQL string?

George John

George John

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

4K+ Views

To cut only the first character, use the substr() function with UPDATE command. The syntax is as follows.UPDATE yourTableName set yourColumnName=substr(yourColumnName, 2);To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table CutStringDemo -> ( -> Value varchar(100) -> ... Read More

Connecting to MySQL database from the command line?

George John

George John

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

3K+ Views

To connect MySQL from the command line, firstly open command prompt. You can do this with the help of shortcut key “Windows + R”. On clicking, a panel will open and you need to type CMD and need to press OK button as shown below −After pressing the OK button, ... Read More

How to form a MySQL Conditional Insert?

George John

George John

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

3K+ Views

For this, you can insert using MySQL dual table. Let us create a table to understand the concept conditional insert. The query to create a table is as follows −mysql> create table ConditionalInsertDemo    -> (    -> UserId int,    -> TotalUser int,    -> NumberOfItems int    -> ... Read More

Why the G modifier in SELECT * FROM table_nameG?

George John

George John

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

187 Views

The \G modifier gets the result in vertical order. If you use \g modifier, then it won’t affect the result. The \g works likesemi-colon.Let us first create a table. The query to create a table is as follows:mysql> create table DemoOfVertical    -> (    -> Id int NOT NULL ... Read More

MySQL command for displaying current configuration variables?

George John

George John

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

2K+ Views

To display current configuration variables, you can use show command. The syntax is as follows −show variables;You can further rewrite the above syntax with LIKE operator. The syntax is as follows −show variables like ‘%anyStringValue%’;The query is as follows displaying an example to fetch some of the configuration variables −mysql> ... Read More

MySQL: selecting rows where a column is null?

George John

George John

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

2K+ Views

To select rows where a column is null, you can use IS NULL from MySQL with the help of where clause.The syntax is as follows −select *from yourTableName where yourColumnName IS NULL;Let us first create a table to understand the concept −mysql> create table NULLDemo1 -> ( ... Read More

How to select all records that are 10 minutes within current timestamp in MySQL?

George John

George John

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

3K+ Views

You can select all records that are 10 minutes within current timestamp using the following syntax−SELECT *FROM yourTableName WHERE yourColumnName > = DATE_SUB(NOW(), INTERVAL 10 MINUTE);To understand the above syntax, let us create a table. The query to create a table is as follows−mysql> create table users    -> ( ... Read More

How to replace values of select return in MySQL?

George John

George John

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

1K+ Views

You can use select case statement for this. The syntax is as follows.select yourColumnName1, yourColumnName2, ...N, case when yourColumnName=1 then 'true' else 'false' end as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table selectReturnDemo -> ... Read More

How to search for exact string in MySQL?

George John

George John

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

1K+ Views

You can use binary to search for exact string in MySQL. The syntax is as follows:SELECT * FROM yourTableName WHERE BINARY yourColumnName = yourStringValue;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ExactSearch    -> (    -> ... Read More

What is the difference between MySQL TINYINT(2) vs TINYINT(1)?

George John

George John

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

2K+ Views

The number 2 and 1 in TINYINT(2) vs TINYINT(1) indicate the display width. There is no difference between tinyint(1) and tinyint(2) except the width.If you use tinyint(2) or even tinyint(1), the difference is the same. You can understand the above concept using zerofill option.tinyint(1) zerofilltinyint(2) zerofillLet us create a table. ... Read More

Advertisements