Karthikeya Boyini has Published 2383 Articles

Counting the number of non-null or nonzero columns in a MySQL table?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:45:00

499 Views

Use if() method for this. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Number1 int,    -> Number2 int    -> ); Query OK, 0 rows affected (1.15 sec)Insert some records in the table ... Read More

Set format specifier in MySQL STR_TO_DATE() and convert string to date

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:39:31

205 Views

Specify format specifier in STR_TO_DATE() method that convertes string to date. Following is the syntax −select STR_TO_DATE(yourColumnName, 'yourFormatSpecifier') from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> AdmissionDate varchar(100) -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert ... Read More

How to use special characters in column names with MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:38:05

1K+ Views

Using backticks around the column name will allow you to use special characters. Let us first create a table −mysql> create table DemoTable    -> (    -> `Student-Id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> `Student-Name` varchar(100),    -> `Student-Age` int    -> ); Query OK, 0 rows ... Read More

Can we use semicolon as a MySQL DEMILITER?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:33:49

86 Views

No, we cannot. If you still did it, then stored procedure won’t get created. Therefore, first you need to change your DELIMITER from semicolon(;) to others like (// ,??..etc). Following is the syntax −DELIMITER // CREATE PROCEDURE yourProcedureName() BEGIN yourStatement1, . . . . N END // DELIMITER ;Let us ... Read More

Can we use PRIMARY KEY( column1, column2) in MySQL to make pairs?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:33:04

119 Views

Yes, you can use below syntax. Following is the syntax −PRIMARY KEY(yourColumnName1, yourColumnName2);Let us first create a table −mysql> create table DemoTable    -> (    -> StudentFirstName varchar(100),    -> StudentLastName varchar(100),    -> StudentAge int,    -> StudentCountryName varchar(100),    -> PRIMARY KEY(StudentFirstName, StudentLastName)    -> ); Query ... Read More

Implement multiple COUNT() in a single MySQL query

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:31:00

671 Views

For this, use CASE statement. Let us first create a table −mysql> create table DemoTable    -> (    -> LastName varchar(100)    -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Smith'); Query OK, 1 row affected ... Read More

How to add multiple intervals to DATE_ADD() in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:16:47

396 Views

The current date and time is as follows −mysql> select now();OutputThis will produce the following output −+---------------------+ | now()               | +---------------------+ | 2019-06-15 12:24:06 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable    ->( ... Read More

Pattern matching in Python with Regex

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:16:45

6K+ Views

What is Regular Expression?In the real world, string parsing in most programming languages is handled by regular expression. Regular expression in a python programming language is a method used for matching text pattern.The “re” module which comes with every python installation provides regular expression support.In python, a regular expression search ... Read More

Performing Google Search using Python code?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jun-2020 09:13:14

1K+ Views

In this article, we will try to do google search using python code, this comes handy in case you are working on a python project and you need to access some data from the web and the search result(from the web) is going to be used inside your project.Prerequisite –You ... Read More

Plotting Google Map using gmplot package in Python?

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

There are numerous ways you can draw geographical coordinates on Google Maps. However, in case you want to save it in a local file, one better way to accomplish is through a python module called gmplot.Python library gmplot allows us to plot data on google maps. gmplot has a matplotlib-like ... Read More

Advertisements