Update Two Columns in a MySQL Database

Ankith Reddy
Updated on 30-Jun-2020 06:32:46

552 Views

You can update two columns using SET command separated with comma(, ). The syntax is as follows −UPDATE yourTableName SET yourColumnName1 = ’yourValue1’, yourColumnName2 = ’yourValue2’ where yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table StudentInformations    -> (    -> StudentId int not null auto_increment,    -> StudentFirstName varchar(20),    -> StudentLastName varchar(20),    -> Primary Key(StudentId)    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into StudentInformations(StudentFirstName, StudentLastName) ... Read More

Get Table Column Names in Alphabetical Order in MySQL

Arjun Thakur
Updated on 30-Jun-2020 06:31:17

2K+ Views

To get the table column names in alphabetical order, you need to use ORDER BY. The syntax is as follows −SELECT anyReferenceName.COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS anyReferenceName WHERE anyReferenceName.TABLE_NAME = ’yourTableName’ ORDER BY anyReferenceName.COLUMN_NAMEFirst, we need to get all the columns and then we need to use ORDER BY. In the above query, we are getting all columns using INFORMATION_SCHEMA.COLUMNS.To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ColumnsOrder    -> (    -> StudentFirstName varchar(20),    -> Id int,    -> StudentAge int,    -> StudentLastName varchar(20)   ... Read More

Find Max and Second Max Salary for a MySQL Employee Table

Ankith Reddy
Updated on 30-Jun-2020 06:20:27

466 Views

You can get max and second max salary from an Employee table using LIMIT OFFSET. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, ....N from yourTableName ORDER BY yourColumnName desc limit 2 offset 0;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table EmployeeMaxAndSecondMaxSalary    -> (    -> EmployeeId int,    -> Employeename varchar(20),    -> EmployeeSalary int    -> ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into EmployeeMaxAndSecondMaxSalary values(1, 'John', 34566); Query OK, 1 row ... Read More

Order By LIKE in MySQL

Arjun Thakur
Updated on 30-Jun-2020 06:19:10

2K+ Views

To order by like in MySQL, use the case statement. The syntax is as follows −SELECT *FROM yourTableName    ORDER BY CASE    WHEN yourColumnName like '%yourPatternValue1%' then 1    WHEN yourColumnName like '%yourPatternValue2%' then 2 else 3 end;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OrderByLikeDemo    -> (    -> Id int,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (1.84 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into OrderByLikeDemo values(100, ... Read More

Create Stack and Queue Using ArrayDeque in Java

Samual Sam
Updated on 30-Jun-2020 06:08:43

533 Views

Create a stack using ArrayDeque.Deque s = new ArrayDeque(); // stack s.push("Bat"); s.push("Mat"); s.push("Cat"); s.push("Rat"); s.push("Hat"); s.push("Fat");Create a queue using ArrayDeque −Deque q = new ArrayDeque(); // queue q.add("Bat"); q.add("Mat"); q.add("Cat"); q.add("Rat"); q.add("Hat"); q.add("Fat");The following is an example.Example Live Demoimport java.util.ArrayDeque; import java.util.Deque; public class Demo {    public static void main(String args[]) {       Deque s = new ArrayDeque();       Deque q = new ArrayDeque();       // stack       s.push("Bat");       s.push("Mat");       s.push("Cat");       s.push("Rat");       s.push("Hat");       s.push("Fat");     ... Read More

Remove Border in NavigationBar in Swift

karthikeya Boyini
Updated on 30-Jun-2020 06:01:47

2K+ Views

To remove the border from a navigation bar in swift, we just need to add a few lines of code. Let’s see how the navigation bar looks when we run it without changing anything.Now let’s try to hide the line/ border shown in the above result.The navigation bar has two things that give it the default view of a grey shadow along with bottom line as shown above. One is the background image, and the other is the shadow image.First, we’ll hide the shadow image, by setting it to empty image and see how it looks.In your viewDidLoad add the ... Read More

Remove Specific Element from a Swift Array

karthikeya Boyini
Updated on 30-Jun-2020 05:59:34

4K+ Views

To remove a specific object from an element in swift, we can use multiple ways of doing it. Let’s see this in the playground with help of an example.First, let’s create an array of String.var arrayOfString = ["a", "b", "c", "f"]We’ll do it with the following methods as shown below:Method 1 − Using the filter method of the array.Arrays in swift have a filter method, which filters the array object depending on some conditions and returns an array of new objects.let modifiedArray = arrayOfString.filter { $0 != "f" } print(modifiedArray)When we run the above code, we get the following result.Method ... Read More

Use UICollectionView in Swift

karthikeya Boyini
Updated on 30-Jun-2020 05:58:40

514 Views

To use collection view in swift, first, we need to create a collection View. We can either drag and drop it to the storyboard, or we can make it programmatically. After that, we need to confirm our class to UICollectionViewDataSource and UICollectionViewDelegate. Also if we need custom cell size and layouts, we need to confirm it to UICollectionViewDelegateFlowLayout.Let’s see the step required to create a collection View programmatically.func initCollection() {    let layout = UICollectionViewFlowLayout()    layout.itemSize = CGSize(width: 50, height: 50)    let collection = UICollectionView.init(frame: self.view.frame, collectionViewLayout: layout)    collection.dataSource = self    collection.delegate = self    collection.backgroundColor ... Read More

Create Custom Dialog Box on iOS App Using Swift

karthikeya Boyini
Updated on 30-Jun-2020 05:57:47

889 Views

To create a dialog box in swift we’ll make use of UIAlertController which is an important part of UIKit. We’ll do this with help of an iOS application and a sample project.First of all, we’ll create an empty project, then inside its default view controller, we’ll perform the following operations.We’ll create an UIAlertController object.let alert = UIAlertController.init(title: title, message: description, preferredStyle: .alert)We’ll create an actionlet okAction = UIAlertAction.init(title: "Ok", style: .default) { _ in    print("You tapped ok")    //custom action here. }We’ll add the action to the alert and present italert.addAction(okAction) self.present(alert, animated: true, completion: nil)Now we’ll convert this ... Read More

Handle Right-to-Left and Left-to-Right Swipe Gestures on iOS App

karthikeya Boyini
Updated on 30-Jun-2020 05:56:36

2K+ Views

To handle gestures in iOS application we’ll create an application with swift and see with help of an example. This can be done in two ways, with storyboard or programmatically.Method 1 − With storyboardFirst we’ll drag a swipe gesture recognizer from our object library and drop it in our View controller in which we want to add the swipe gesture.Then click on the gesture, press control and drag in your view controller class to create its connection.Make sure the sender of that action is UISwipeGestureRecognizer and the action looks something like this:@IBAction func swipeMade(_ sender: UISwipeGestureRecognizer) { }Now the swipe ... Read More

Advertisements