Ankith Reddy has Published 1070 Articles

Populating a table from query results in MySQL?

Ankith Reddy

Ankith Reddy

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

432 Views

To populate a table from query results, use the following syntax:INSERT yourTableName(yourColumnName1, yourColumnName2, yourColumnName3, ..........N) SELECT yourColumnName1, yourColumnName2, yourColumnName3, ..........N FROM yourAnotherTableName;To understand the above syntax, let us create a table. The first table is as follows with some records. The query to create a table is as follows:mysql> create ... Read More

What is the difference between MySQL BOOL and BOOLEAN column data types?

Ankith Reddy

Ankith Reddy

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

950 Views

BOOL and BOOLEAN both acts like TINYINT(1). You can say that both are synonyms for TINYINT(1).BOOLEANHere is an example of BOOLEAN. The query to create a table with column boolean type.mysql> create table Demo -> ( -> isVaidUser boolean -> ); ... Read More

How to remove double or more spaces from a string in MySQL?

Ankith Reddy

Ankith Reddy

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

695 Views

You can create a function to remove double or more spaces from a string. The syntax is as follows:DELIMITER // create function yourFunctionName(paramter1, ...N) returns datatype; begin //your statement. end; // DELIMITER ;Here’s how to create a function:mysql> delimiter // mysql> create function function_DeleteSpaces(value varchar(200)) returns varchar(200)    -> begin ... Read More

How to concat Values in MySQL Query and to handle Null values as well?

Ankith Reddy

Ankith Reddy

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

1K+ Views

You can use CONCAT() method to concatenate values while IFNULL() method is used to handle NULL values. The syntax is as follows:SELECT CONCAT('anyStringValue:', IFNULL(yourColumnName, 'anyStringValue’)) 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 ConcatValues ... Read More

What does “unsigned” in MySQL mean and when to use it?

Ankith Reddy

Ankith Reddy

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

11K+ Views

The “unsigned” in MySQL is a data type. Whenever we write an unsigned to any column that means you cannot insert negative numbers. Suppose, for a very large number you can use unsigned type.The maximum range with unsigned int is 4294967295.Note: If you insert negative value you will get a ... Read More

How do I add more members to my ENUM - type column in MySQL?

Ankith Reddy

Ankith Reddy

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

364 Views

You can use alter command. The syntax is as follows −ALTER TABLE yourTableName MODIFY COLUMN yourColumNam enum(yourOldValue1, yourOldValue2, ....N, yourNewValue1, yourNewValue2, ....N);To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table EnumDemo -> ( ... Read More

How to subtract 30 days from the current datetime in MySQL?

Ankith Reddy

Ankith Reddy

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

4K+ Views

To subtract 30 days from current datetime, first we need to get the information about current date time, then use the now() method from MySQL. The now() gives the current date time.The method to be used for this is DATE_SUB() from MySQL. Here is the syntax to subtract 30 days ... Read More

What is the difference between SQL and MySQL?

Ankith Reddy

Ankith Reddy

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

468 Views

SQLSQL is a type of language that can be used to utilize your database. It is a base language for databases like MySQL, SQL Server, Oracle etc. SQL stands for Structure Query Language and it can be used to utilize the relational database management system.This can also be used for ... Read More

Create MySQL query to create a table from an existing table?

Ankith Reddy

Ankith Reddy

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

334 Views

You can use CREATE TABLE command to create a table from an existing table. The syntax is as follows:CREATE TABLE yourNewTableName LIKE yourOldTableNameTo understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ShowCreateTableCommand    -> (    -> Id ... Read More

Which rows are returned while using LIMIT with OFFSET in MySQL?

Ankith Reddy

Ankith Reddy

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

249 Views

Suppose the LIMIT is 4 and OFFSET is 6 then it will return the rows from 7 to 10 i.e. will end with row 10. The LIMIT 4 and OFFSET 6 returns row 7, 8, 9, 10.You can understand the above concept by implementing LIMIT and OFFSET. Let us create ... Read More

Advertisements