Anvi Jain has Published 569 Articles

Using group by on two fields and count in MySQL?

Anvi Jain

Anvi Jain

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

619 Views

To implement GROUP BY on two fields and count, let us create a table. The following is the query to create a table −mysql> create table GroupByTwoFieldsDemo    −> (    −> Id int,    −> Name varchar(200)    −> ); Query OK, 0 rows affected (0.53 sec)Let us insert ... Read More

Get all characters before space in MySQL?

Anvi Jain

Anvi Jain

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

1K+ Views

In order to get all characters before space in MySQL, you can use left() function from the MySQL. The syntax is as follows −select left(yourColumnName, LOCATE(' ', yourColumnName) - 1) as anyVariableName from yourTableName;To understand the above concept, let us create a table.The query to create a table is as ... Read More

How to create a Cumulative Sum Column in MySQL?

Anvi Jain

Anvi Jain

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

3K+ Views

To create a cumulative sum column in MySQL, you need to create a variable and set to value to 0. Cumulative sum increments the next value step by step with current value.Firstly, you need to create a variable with the help of SET. The syntax is as follows −set @anyVariableName:= ... Read More

Detect current device with UIUserInterfaceIdiom in Swift

Anvi Jain

Anvi Jain

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

3K+ Views

To detect current device with iOS/Swift we can use UserInterfaceIdiom. It is an enum in swift, which tells which device is being used.The interface idiom provides multiple values in it’s enum which are.case unspecified @available(iOS 3.2, *) case phone // iPhone and iPod touch style UI @available(iOS 3.2, *) case ... Read More

Strip last two characters of a column in MySQL?

Anvi Jain

Anvi Jain

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

2K+ Views

You can strip last two characters with the help of SUBSTRING() and CHAR_LENGTH() methods. The syntax is as follows −select yourColumnName, SUBSTRING(yourColumnName, 1, CHAR_LENGTH(yourColumnName) - 2) AS anyVariableName from yourTableName;To understand the above syntax, let us create a table −mysql> create table LastTwoCharacters −> ( ... Read More

How to resolve the error that occurs while using a reserved word as a table or column name in MySQL?

Anvi Jain

Anvi Jain

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

1K+ Views

This error occurs when you try to use a reserved word as a table or column name. It can occur due to −Case 1: Whenever you use reserved word as a table name −mysql> create table insert −> ( −> Id int −> );The error is as follows −ERROR 1064 ... Read More

How to Add Live Camera Preview to UIView in Swift?

Anvi Jain

Anvi Jain

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

835 Views

To add a live camera preview to our default UIView in swift we can either use AVFoundation framework of iOS SDK or native UIImagePickerController(). In this example we’ll be using ImagePicker as our aim is to present camera preview on the UIView and Imagepicker is suitable for that task. AVFoundation ... Read More

Delete more than one rows from a table using id in MySQL?

Anvi Jain

Anvi Jain

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

1K+ Views

You can use IN statement to delete more than one rows from a table using id in MySQL. The syntax is as follows −delete from yourTableName where yourColumnName in(value1, value2, .....valueN);To understand the above syntax, let us create a table. The following is the query to create a table.mysql> create ... Read More

MYSQL select DISTINCT values from two columns?

Anvi Jain

Anvi Jain

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

5K+ Views

To select distinct values in two columns, you can use least() and greatest() function from MySQL.Let us create a table with two columns −mysql> create table SelectDistinctTwoColumns    −> (    −> StudentId int,    −> EmployeeId int    −> ); Query OK, 0 rows affected (0.60 sec)Now you can ... Read More

How to make iPhone vibrate using Swift?

Anvi Jain

Anvi Jain

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

2K+ Views

To make an iPhone vibrate using swift we’ll use two different methods. First create a new project and add Four different buttons to the main View controller.Now import the AudioToolbox framework in your view controller class.For the first button add an action and write the following code as shown below:@IBAction ... Read More

Advertisements