Vrundesha Joshi has Published 345 Articles

Check if a user exists in MySQL and drop it?

Vrundesha Joshi

Vrundesha Joshi

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

1K+ Views

To check how many users are present in MySQL, use MySQL.user table. The syntax is as follows to check how many users are present.mysql> SELECT User FROM mysql.user;The following output displays the users −+------------------+ | User | +------------------+ ... Read More

Compare DATE string with string from MySQL DATETIME field?

Vrundesha Joshi

Vrundesha Joshi

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

1K+ Views

You can compare DATE string with string from DATETIME field with the help of DATE() function in MySQL.The syntax is as follows −select *from yourTableName where DATE(yourColumnName) = ’anyDateString’;To understand the above syntax, let us create a table and set some datetime values in the table. The query to create ... Read More

Get the fields in each constraint in MySQL

Vrundesha Joshi

Vrundesha Joshi

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

36 Views

Let’s say we have a database “business” with number of tables. If you want to Get the fields in each constraint, then use the below query.The below query is to get the fields in each one of those constraints −mysql> select * −> from information_schema.key_column_usage −> where constraint_schema = 'business';The ... Read More

How to select domain name from email address in MySQL?

Vrundesha Joshi

Vrundesha Joshi

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

3K+ Views

To select domain name from email address, you can use in-built SUBSTRING_INDEX() function from MySQL.To understand the concept, let us create a table. The following is the query to create a table.mysql> create table selectDomainNameOnly −> ( −> UserEmailAddress varchar(200) −> ... Read More

Getting last 5 character of a string with MySQL query?

Vrundesha Joshi

Vrundesha Joshi

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

17K+ Views

To get the first n characters of string with MySQL, use LEFT(). To get the last n char of string, the RIGHT() method is used in MySQL.The syntax for RIGHT() method is as follows −SELECT RIGHT(yourColumnName, valueOfN) as anyVariableName from yourTableName;To understand the above concept, let us create a table. ... Read More

What should I do? Select int as currency or convert int to currency format in MySql?

Vrundesha Joshi

Vrundesha Joshi

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

344 Views

To convert int to current format, use CONCAT() with FORMAT() function from MySQL.The syntax is as follows −SELECT CONCAT(‘CurrencySymbol’, FORMAT(yourColumnName, valueAfterDecimal)) as AnyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table −mysql> create table AddingCurrencySymbolDemo −> ( ... Read More

MySQL query to extract first word from a field?

Vrundesha Joshi

Vrundesha Joshi

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

3K+ Views

To extract first word from a field, use in-built SUBSTRING_INDEX() function. The syntax is as follows −SELECT SUBSTRING_INDEX(yourColumnName, ’ ‘, 1) as anyVariableName from yourTableName;In the above query, if you use -1 in place of 1 then you will get the last word. To understand the above concept, let us ... Read More

Combine date and time column into a timestamp in MySQL?

Vrundesha Joshi

Vrundesha Joshi

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

11K+ Views

To combine date and time column into a timestamp, you can use cast() function with concat().The syntax is as follows −select cast(concat(yourDateColumnName, ' ', yourTimeColumnName) as datetime) as anyVariableName from yourTableName;In the above concept, you will use cast() when your date and time is in string format. The cast() function ... Read More

How to echo print statements while executing an SQL script?

Vrundesha Joshi

Vrundesha Joshi

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

2K+ Views

To perform echo print statements while executing SQL scripts, use the following syntax.The syntax is as follows −SELECT ‘anyStringValue as’ ‘;The query is as follows −mysql> select 'This is a SQL Script' AS' ';The following is the output −+----------------------+ | ... Read More

Get maximal GPS precision on mobile browser

Vrundesha Joshi

Vrundesha Joshi

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

161 Views

Built-in browser for Android will not give you accurate GPS location for security reasons. Test it with different web browsers that would need permissions to get the accurate location from GPS when installed.After switching GPS off, the data is received with < 10 meters accuracy.Do not use Android Browser for ... Read More

Advertisements