Ankith Reddy

Ankith Reddy

730 Articles Published

Articles by Ankith Reddy

Page 64 of 73

Changing Column in MySQL from int to double?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 4K+ Views

To change the column in MySQL from int to double you need to use ALTER TABLE command.The syntax is as follows:ALTER TABLE yourTableName modify column yourColumnName DOUBLE NOT NULL;If you want NULL value then remove NOT NULL from the above syntax. The syntax is as follows:ALTER TABLE yourTableName modify column yourColumnName DOUBLE;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table IntToDoubleDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(10),    -> CylinderVolume int,    -> PRIMARY KEY(Id)    -> ); Query OK, ...

Read More

MySQL stored-procedure: out parameter?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 1K+ Views

Here is a stored procedure that takes one parameter for input (IN) and second parameter for output (OUT)mysql> delimiter // mysql> create procedure Sp_SQRT(IN Number1 INT, OUT Number2 FLOAT) -> Begin -> set Number2=sqrt(Number1); -> end; -> // Query OK, 0 rows affected (0.24 sec) mysql> delimiter ;Call the stored procedure and send the value to the user variable. The syntax is as followsCALL yourStoredProcedureName(anyIntegerValue, @anyVariableName);Check what value is stored in the variable @anyVariableName. The syntax is as followsSELECT @anyVariableName;Created the stored procedure with the name ‘Sp_SQRT’. The ...

Read More

Split a string and loop through values in MySQL Procedure?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 5K+ Views

To split a string and loop through all values in MySQL procedure, you do not need to use REPLACE() function. To understand, first create a stored procedure and after that create a table and call the stored procedure with some values. The value will be inserted into the table.The query to create a stored procedure is as follows:mysql> DELIMITER // mysql> CREATE PROCEDURE SP_SplitString(Value longtext)    -> BEGIN    -> DECLARE front TEXT DEFAULT NULL;    -> DECLARE frontlen INT DEFAULT NULL;    -> DECLARE TempValue TEXT DEFAULT NULL;    -> iterator:    -> LOOP      -> IF LENGTH(TRIM(Value)) ...

Read More

Android Working with Recycler View

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 2K+ Views

Recycler view is a more advanced version of listview and works based on View holder design pattern. Using recyclerview we can show grids as well as a list of items.This example demonstrates how to integrate RecyclerView by creating a beautiful student records app that displays student name with age.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Open build.gradle and add Recycler view library dependency.apply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {       applicationId "com.example.andy.tutorialspoint"   ...

Read More

How to display records vertically in MySQL command line?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 3K+ Views

You can use backward slash followed by G i.e. \G instead of semicolon(;). The syntax is as follows to show records vertically in MySQL command line.SELECT *FROM yourTableName\GTo understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table showRecordsVertically -> ( -> Id int, -> Name varchar(100), -> Age int -> ); Query OK, 0 rows affected (2.10 sec)Insert some records in the table using insert command. The query is as followsmysql> insert into showRecordsVertically ...

Read More

How to get the sum for every distinct value in another column in MySQL?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 3K+ Views

You can get the sum for every distinct value in another column with the help of aggregate function SUM() with GROUP BY command. To understand the above concept, let us create a table. The query to create a table is as follows:mysql> create table SumOfEveryDistinct -> ( -> Id int not null, -> Amount int -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into SumOfEveryDistinct values(10, 100); Query OK, 1 row affected (0.19 ...

Read More

How to use GROUP BY to concatenate strings in MySQL and how to set a separator for the concatenation?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 9K+ Views

To concatenate strings in MySQL with GROUP BY, you need to use GROUP_CONCAT() with a SEPARATOR parameter which may be comma(‘) or space (‘ ‘) etc.The syntax is as follows:SELECT yourColumnName1, GROUP_CONCAT(yourColumnName2 SEPARATOR ‘yourValue’) as anyVariableName FROM yourTableName GROUP BY yourColumnName1;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table GroupConcatenateDemo    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command. The query to insert record is as follows:mysql> insert ...

Read More

Combine INSERT, VALUES, and SELECT in MySQL

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 1K+ Views

You can combine the insert, values and select statement using below syntaxinsert into yourFirstTableName(yourColumnName1, yourColumnName2, .......N) select yourColumnName1, yourColumnName2, .......N from yourSecondTableName where yourCondition;To understand the above syntax, let us create two tables in which first table will get the record from the second table.Let us create the first table without any records. The query to create a table is as followsmysql> create table CombiningInsertValuesSelect    -> (    -> EmployeeId varchar(10),    -> EmployeeName varchar(100),    -> EmployeeAge int    -> ); Query OK, 0 rows affected (6.95 sec)Now you can create the second table with some records. The ...

Read More

How to find all uppercase strings in a MySQL table?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 1K+ Views

To find all upper case strings in a MySQL table, you need to use BINARY UPPER() function. The syntax is as follows:SELECT *FROM yourTableName WHERE yourColumnName=BINARY UPPER(yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table FindUpperCaseDemo    -> (    -> Id int,    -> FirstName varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (1.04 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into FindUpperCaseDemo values(1, 'John', 23); Query OK, 1 row affected (0.17 sec) mysql> ...

Read More

Limit length of longtext field in MySQL SELECT results?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 1K+ Views

You can use SUBSTRING() from MySQL to limit length of strings. The syntax is as followsSELECT SUBSTRING(yourColumnName, 1, yourIntegerValueToGetTheCharacters) as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table limitLengthOfLongTextDemo -> ( -> sentence LONGTEXT -> ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert command. The query is as followsmysql> insert into limitLengthOfLongTextDemo values('This is the introduction to MySQL'); Query OK, 1 row affected (0.17 sec) mysql> insert into ...

Read More
Showing 631–640 of 730 articles
« Prev 1 62 63 64 65 66 73 Next »
Advertisements