Articles on Trending Technologies

Technical articles with clear explanations and examples

Return order of MySQL SHOW COLUMNS?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 420 Views

To return order of MySQL SHOW COLUMNS, you need to use ORDER BY clause. The syntax is as follows −SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ‘yourTableName’ AND column_name LIKE 'yourStartColumnName%' ORDER BY column_name DESC;Let us create a table in database TEST. The query to create a table is as follows −mysql> create table OrderByColumnName -> ( -> StudentId int, -> StudentFirstName varchar(10), -> StudentLastName varchar(10), -> StudentAddress varchar(20), -> StudentAge int, -> StudentMarks int ...

Read More

How to update field to add value to existing value in MySQL?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 8K+ Views

You can update field to add value to an existing value with the help of UPDATE and SET command. The syntax is as follows −UPDATE yourTableName SET yourColumnName = yourColumnName+integerValueToAdd WHERE yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table addingValueToExisting    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(30),    -> GameScore int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.58 sec)Insert records in the table using insert command. The query is as follows −mysql> insert ...

Read More

What is a Blue Paradise Fish and what is its lifespan?

Knowledge base
Knowledge base
Updated on 30-Jul-2019 641 Views

Among the freshwater Aquarium fishes, the Blue Paradise Fish or the Paradise Gourami is the most acclaimed one after the famous Goldfish. This beautiful small fish, which belongs to gourami family has a scientific name called as Macropodus opercularis. The male fish of this bright coloured species grows up to 10cm, while the female grows to 8cm. These were the first ornamental fishes brought to western aquariums which were also imported to France during 1869.A WarriorThis small beauty is most pugnacious in nature. Paradise fish can combat, fight and is also potential to kill. This fish tends to fight with ...

Read More

MySQL how to declare a datetime variable?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 3K+ Views

To declare a datetime variable, you need to use a user-defined variable using the SET command. The syntax is as follows −SET @anyVariableName=’yourdatetimeValue’;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table datetimeVariables -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(10), -> ArrivalDatetime datetime, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. The query to ...

Read More

Two columns as primary key with auto-increment in MySQL?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 1K+ Views

Achieve this using MyISAM Engine. Here is an example of two columns as primary key with auto-increment.Creating a table with two columns as primary key −mysql> create table TwoPrimaryKeyTableDemo -> ( -> Result ENUM('First', 'Second', 'Third', 'Fail') not null, -> StudentId int not null auto_increment, -> StudentName varchar(200) not null, -> Primary key(Result, StudentId) -> ) -> ENGINE=MyISAM; Query OK, 0 rows affected (0.20 sec)Inserting records into tablemysql> insert into TwoPrimaryKeyTableDemo(StudentName, Result) values('John', 'Fail'); Query OK, 1 row affected ...

Read More

MySQL CAST as DATE?

George John
George John
Updated on 30-Jul-2019 628 Views

There is no difference between cast as Date and date() function in MySQL.The syntax of both cast() and date() is as follows −cast(yourDateTimeColumnName as Date) date(yourDateTimeColumnName)Both functions internally call Item_date_typecast. To check both the functions, let us create a table. The query to create a table is as follows −mysql> create table CastAsDateDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> ArrivalTime datetime,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.71 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into ...

Read More

What would you do if you were made a superhero for a day?

Ridhi Arora
Ridhi Arora
Updated on 30-Jul-2019 7K+ Views

A superhero is a person who does heroic deeds. So, in order to be a superhero, you need the power to accomplish good deeds.My WishFirstly, One of my superpowers would be to have the ability to fly. I would want to fly because that way I could fly over the town and see if people need help or not. I will also see whether they are happy or not so that I can make them happy in some manner.Secondly, I would want to be able to have super strength. By super strength I mean, to do anything and everything.Lastly, I ...

Read More

Should I store a field PRICE as an int or as a float in the database?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 956 Views

You do not need to store a field PRICE as an int or as float in the database. For this, you can set the DECIMAL()..Most of the time integers can be used to represent the float point numbers and these integers are internally cast into DECIMAL() data type. Therefore, if you have field PRICE then always use DECIMAL() data type. The syntax is as follows −DECIMAL(M, D);Here, M represents the ‘TotalNumberOfDigit’ and D represents the ‘Number OfDigitAfterDecimalPoint’.To understand the above concept, let us create a table with field PRICE as DECIMAL data type. The query is as follows −mysql> create ...

Read More

Inserting multiple rows in MySQL?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 7K+ Views

Insert multiple rows in MySQL with the help of “values”. You can enclose the values with parentheses set with comma separation. The syntax is as follows to insert multiple rows in MySQL.insert into yourTableName(yourColumnName1, yourColumnName2, ..............yourColumnNameN) values(value1, value2, ...valueN), (value1, value2, ...valueN), (value1, value2, ...valueN), ...........((value1, value2, ...valueN);Let us now first create a table in MySQL −mysql> create table InsertMultipleRowsDemo -> ( -> Id int, -> Name varchar(200), -> Age int -> ); Query OK, 0 rows affected (0.45 sec)Apply the above syntax to insert ...

Read More

Selecting a single row in MySQL?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 2K+ Views

If you want to select a single row on the basis of primary key, use the WHERE clause. The syntax is as follows −SELECT * FROM yourTableName WHERE yourPrimaryKeyColumnName = someValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table selectWithPrimaryKey    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Age int,    -> Marks int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. The query is ...

Read More
Showing 60351–60360 of 61,297 articles
Advertisements