MySQLi Articles

Page 268 of 341

How can I set a MySQL database to use MyISAM by default?

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

To set the default storage engine, use the following syntax −set @@default_storage_engine = ’yourEngineType’;Now implement the above syntax to set the default engine to MyISAM. The query is as follows −mysql> set @@default_storage_engine = 'MyISAM'; Query OK, 0 rows affected (0.05 sec)Now you can check the default engine type with the help of SELECT statement. The query is as follows −mysql> select @@default_storage_engine;The following is the output displaying the engine as MyISAM −+--------------------------+ | @@default_storage_engine | +--------------------------+ | MyISAM | +--------------------------+ 1 ...

Read More

How to alter a MySQL Column from varchar(30) to varchar(100)?

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

You need to use ALTER TABLE command along with MODIFYThe syntax is as followsALTER TABLE yourTableName MODIFY COLUMN yourColumnName varchar(100) NOT NULL;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table syntaxOfAlterCommandDemo    -> (    -> UserId int,    -> UserName varchar(30),    -> UserAge int,    -> UserCityName varchar(50)    -> ); Query OK, 0 rows affected (0.51 sec)Let us check the description of the table.The query is as followsmysql> desc syntaxOfAlterCommandDemo;The following is the output+--------------+-------------+------+-----+---------+-------+ | Field | Type ...

Read More

How to find strings with a given prefix in MySQL?

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

You can use LIKE operator to find strings with a given prefix.The syntax is as followsselect *from yourTableName where yourColumnName LIKE 'yourPrefixValue%';To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table findStringWithGivenPrefixDemo    -> (    -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserMessage text    -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hi Good Morning !!!'); Query OK, 1 row affected (0.17 sec) mysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hey ...

Read More

How to set all values in a single column MySQL Query?

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

To set all values in a single column MySQL query, you can use UPDATE command.The syntax is as follows.update yourTableName set yourColumnName =yourValue;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table setAllValuesDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20),    -> Amount int    -> ); Query OK, 0 rows affected (0.64 sec)Now you can insert some records in the table using insert command.The query is as follows.mysql> insert into setAllValuesDemo(Name, Amount) values('John', 2345); Query OK, 1 row affected ...

Read More

How to get file extension of file as a result of MySQL query?

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

In order to get file extension of file as a result of SQL query, you can use SUBSTRING_INDEX().The syntax is as followsselect substring_index(yourColumnName, '.', -1) as anyAliasName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table getFileExtensionDemo    -> (    -> File_Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> File_Name text    -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into getFileExtensionDemo(File_Name) values('John.AllMySQLConcept.doc'); Query OK, 1 row affected (0.17 sec) mysql> ...

Read More

How to check whether a stored procedure exist in MySQL?

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

Let us first create a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE ExtenddatesWithMonthdemo(IN date1 datetime, IN NumberOfMonth int )    -> BEGIN    -> SELECT DATE_ADD(date1, INTERVAL NumberOfMonth MONTH) AS ExtendDate;    -> END;    -> // Query OK, 0 rows affected (0.20 sec) mysql> DELIMITER ;Now you check whether the stored procedure exists with the help SHOW CREATE command.The query is as follows −mysql> SHOW CREATE PROCEDURE ExtenddatesWithMonthdemo; The following is the output displaying the details of the stored procedure we created above: +--------------------------+--------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ | Procedure                | sql_mode ...

Read More

How to select from MySQL table A that does not exist in table B?

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

You can use IN operator to select from one table that does not exist in another. To understand the above syntax, let us create a table.The first table name is A and second table name is B. The query to create a table is as followsmysql> create table A    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.56 sec)Now you can insert some records in the table using insert command.The query is as followsmysql> insert into A values(10); Query OK, 1 row affected (0.23 sec) mysql> insert into A values(20); Query OK, 1 ...

Read More

Can we add a column to a table from another table in MySQL?

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

Yes, we can add a column to a table from another table. Let us first create two tables. The query to create a table is as follows −mysql> create table FirstTable    -> (    -> UserId int,    -> UserName varchar(20)    -> ); Query OK, 0 rows affected (1.48 sec)Now create the second table. The query to create the second table is as follows −mysql> create table SecondTable    -> (    -> UserId int,    -> UserAge int    -> ); Query OK, 0 rows affected (1.57 sec)Now, add column Age to the first table. Firstly, ...

Read More

MySQL: Testing connection with query?

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

Use any predefined function with select query or you can print some words with the select query in order to test connection with query.The syntax is as follows.SELECT yourValue;The select query with predefined function is as follows.The syntax is as follows.SELECT anyPredefinedFunctionName();Now you can implement the above syntax in order to test connection with query.Case 1 -The query is as follows.mysql> select "This is MySQL" as Display;The following is the output.+---------------+ | Display | +---------------+ | This is MySQL | +---------------+ 1 row in set (0.00 sec)Case 2 -The query is as follows.mysql> select ...

Read More

Get the returned record set order in MySQL IN clause?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 176 Views

For returned record set order, you need to use FIND_IN_SET() function. For an example, let us create a table.mysql> create table returnRecordSetOrderDemo    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (1.01 sec)Insert some records in the table using insert command.The query is as follows.mysql> insert into returnRecordSetOrderDemo values(100, 'John'); Query OK, 1 row affected (0.13 sec) mysql> insert into returnRecordSetOrderDemo values(130, 'Carol'); Query OK, 1 row affected (0.13 sec) mysql> insert into returnRecordSetOrderDemo values(103, 'Bob'); Query OK, 1 row affected (0.17 sec) mysql> insert into returnRecordSetOrderDemo values(134, 'Sam'); Query OK, ...

Read More
Showing 2671–2680 of 3,404 articles
« Prev 1 266 267 268 269 270 341 Next »
Advertisements