Add Column Values in MySQL Without Using Aggregate Function

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

402 Views

You can add column values without using aggregate function like sum(). For that, the syntax is as follows −SELECT *, (yourColumnName1+yourColumnName2+yourColumnName3, ....N) 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 AddingColumnDemo    -> (    -> StudentId int,    -> StudentName varchar(20),    -> MathMarks int,    -> PhysicsMarks int,    -> ChemistryMarks int    -> ); Query OK, 0 rows affected (0.82 sec)Insert records in the table using insert command. The query is as follows −mysql> insert into AddingColumnDemo values(1, 'John', 35, ... Read More

MySQL Insert a Row and Get the Content

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

145 Views

In order to do insert a row and get the content, you need to use stored procedure, First, you need to create a table. After that you need to create a stored procedure that will insert a row and get the content to the end user.To do the above task, let us first create a table. The query to create a table is as follows:mysql> create table InsertRecord_SelectTable -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> PRIMARY KEY(Id) -> ); Query ... Read More

Difference Between the Indian and US Education System

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

5K+ Views

The Indian Education System that exists today in India is influenced mainly by the British System of Education. The Education System is considered to be one of the most advanced in the world. There are some strengths and weaknesses in both the systems that exist today.There are many differences between the Indian and the American Education systems.3 years v/s 4 years graduation − The system that is followed in India is 10+2+3 years for streams like commerce, science, social sciences, humanities, management, and media.(Engineering degree is an exception which is a 4-year long course).However, in the US, the system followed ... Read More

Alter Table Column Datatype on Multiple Columns in MySQL

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

104 Views

To add more than 1 column with ALTER table command, you can use MODIFY column command. The syntax is as follows −alter table yourTableName modify column yourColumnName1 dataType, modify column yourColumnName2 dataType, . . . modify column yourColumnNameN dataTypeTo understand the above syntax, let us create a table. The following is the query −mysql> create table AddColumn    −> (    −> StudentID int,    −> StudentName varchar(200)    −> ); Query OK, 0 rows affected (0.49 sec)Above we have two columns in the table “AddColumn”. In this we will see how to modify more than one column datatype −mysql> ... Read More

Declare a Variable in MySQL for a Normal Query

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

4K+ Views

You can declare a variable using @anyVariablename which is a session variable. To create a session variable, you need to use SET command.The syntax is as followsSET @anyVariableName:=anyValue;You can declare a local variable using DECLARE command. The syntax is as followsDECLARE yourVariableName datatypeYou can set the default value at the time of creating a variable. The syntax is as followsDECLARE yourVariableName datatype default ‘yourValue’Here is the demo of session variable. To understand it, let us create a table.The query to create a table is as followsmysql> create table SessionVariableDemo    -> (    -> EmployeeId varchar(10),    -> EmployeeName varchar(30), ... Read More

Detect Current Device with UIUserInterfaceIdiom in Swift

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 pad // iPad style UI @available(iOS 9.0, *) case tv // Apple TV style UI @available(iOS 9.0, *) case carPlay // CarPlay style UIIn swift interfaceIdiom can be used in the following way:print(UIDevice.current.userInterfaceIdiom) if UIDevice.current.userInterfaceIdiom == .phone { print("running on iPhone") }When we run the above code ... Read More

What Makes Something Go Viral

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

147 Views

The internet is the most craziest place we have ever witnessed because there are content creators who put all their sweat and blood to create the best content but hardly get the desired response from the audience out there. On the other hand, some content despite being substandard, make people go gaga about it within minutes and hours. This made me ponder upon the key factor involved in it. What makes any content whether good, better or best go viral.TastemakersThey are influential people who introduce content they want to make viral to common people and get the content in limelight. ... Read More

MySQL Delimiter Error: Causes and Solutions

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

2K+ Views

The MySQL delimiter occurs when you are using a pipe delimiter(|) with semicolon (;) and using MySQL version lower than 8.0.12.MySQL treats the pipe (|) as one delimiter and semicolon (;) is another delimiter. Therefore, do not confuse the MySQL delimiter with pipe as well as semicolon.Note: Here, we are using MySQL version 8.0.12. The pipe delimiter works fine with semicolon. If you are using version lower than 8.0.12, then this leads to a delimiter error.Here is the working of MySQL delimiter:mysql> delimiter |; mysql> create procedure getSumOfTwoNumbers() -> begin -> select 2+3 as ... Read More

Rearrange MySQL Columns

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

635 Views

To rearrange the MySQL columns, check the column arrangement with the help of show create command. The syntax is as follows −show create table yourTableName;The syntax to rearrange the MySQL columns is as follows −alter table yourTableName change column yourColumnName yourColumnName dataType firstFor the same purpose, you can use the after keyword. The syntax is as follows −alter table yourTableName change column yourColumnName yourColumnName dataType after yourSpecificColumnName;Let us first check the column arrangement for the already created table “AddColumn” −mysql> show create table AddColumn; The following is the output −+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table     | Create Table       ... Read More

Insert Decimal into MySQL Database

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

8K+ Views

To insert decimal into MySQL, you can use DECIMAL() function from MySQL. The syntax is as followsyourColumnName DECIMAL(TotalDigit, DigitAfterDecimalPoint);To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table DecimalInsert    -> (    -> Id int,    -> Name varchar(100),    -> Amount DECIMAL(4, 2)    -> ); Query OK, 0 rows affected (0.65 sec)Insert the decimal value using insert command. The query is as followsmysql> insert into DecimalInsert values(1, 'John', 12.4); Query OK, 1 row affected (0.15 sec) mysql> insert into DecimalInsert values(2, 'Carol', 12.34); Query OK, ... Read More

Advertisements