Found 4219 Articles for MySQLi

MySQL LIMIT clause equivalent for SQL SERVER?

Arjun Thakur
Updated on 25-Jun-2020 08:27:01

270 Views

Firstly, we need to create a table to understand the limit clause (as we want for SQL server).We will create a table with the help of CREATE command.Creating a tablemysql> CREATE table limitDemo -> ( -> id int, -> primary key(id) -> ); Query OK, 0 rows affected (0.58 sec)After that, let us insert records into the table −mysql> INSERT into limitDemo values(1); Query OK, 1 row affected (0.16 sec) mysql> INSERT into limitDemo values(2); Query OK, 1 row affected (0.12 sec) mysql> INSERT into limitDemo values(3); Query OK, 1 row affected (0.11 sec) mysql> INSERT into ... Read More

Check if table exist without using “select from” in MySQL?

George John
Updated on 25-Jun-2020 08:32:17

174 Views

We can achieve this with the help of SHOW command. Firstly, I will use my database with the help of USE command −mysql> USE business; Database changedWe are in the “business” database now. After that, we can check that how many tables are available for this database. The query is as follows −mysql> SHOW tables; The following is the output+------------------------+ | Tables_in_business     | +------------------------+ | addcolumntable         | | autoincrement          | | autoincrementtable     | | bookindexes            | | chardemo           ... Read More

How to add 5 hours to current time in MySQL?

Chandu yadav
Updated on 25-Jun-2020 08:32:37

2K+ Views

To add 5 hours in current time, we will use now() function from MySQL. The syntax is as follows −SELECT date_add(now(),interval some integer value hour);Now, I am applying the above query to add 5 hours to current time. The query is as follows −mysql> SELECT date_add(now(),interval 5 hour); The following is the output+---------------------------------+ | date_add(now(),interval 5 hour) | +---------------------------------+ | 2018-10-11 15:59:23 | +---------------------------------+ 1 row in set (0.00 sec)Look at the output above, it has increased the current time by 5 hours

MyISAM versus InnoDB in MySQL?

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

214 Views

Both are engine types. Here is the query by which we can get to know which engine type and tables are being used. Firstly, we will choose the database with the help of USE command − mysql> USE business; Database changed Here is the query through which we can know which table or engine is being used − mysql> SHOW table status; The following is the output +------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ |Name | Engine | Version | Row_format | ... Read More

How to convert an MySQL database characterset and collation to UTF-8?

Ankith Reddy
Updated on 25-Jun-2020 08:10:50

248 Views

Firstly, we will check which MySQL version is currently being used with the help of version() function −The query is as follows −mysql> SELECT version();The following is the output+-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)As you can see in the above output, version 8.0.12 is being used. Now, we can check the current character encoding using the following syntax −SELECT CCSA.character_set_name FROM information_schema.`TABLES`T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name -> =T.table_collation AND T.table_schema = "yourDatabaseName" AND T.table_name = "yourTableName";Apply the above query −mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES`T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name ... Read More

Which one is preferred between a large table or multiple small tables in MySQL?

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

159 Views

It is very difficult to say whether to prefer one large table or multiple small tables. It depends − On the application we are using. On database normalization However, there are many key points, through which we can say that multiple small tables are good in that situation. Suppose many developers are going to develop multiple tables, then there is a need to split them into multiple small tables. A situation when you are giving authority to many developers. This authority is for different parts of data. In this case, a need arise to split into multiple small ... Read More

How can we use nested transactions allowed in MySQL?

Ankith Reddy
Updated on 25-Jun-2020 08:11:48

280 Views

We can allow multiple transactions with the help of START command and SAVEPOINT. Let us create a table with the help of CREATE command.Creating a tablemysql> CREATE table transactionDemo -> ( -> id int auto_increment, -> primary key(id) -> ); Query OK, 0 rows affected (0.76 sec)After that, I will begin a transaction with the help of START command −mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec)After that, I am inserting the following record with the help of INSERT command −mysql> INSERT into transactionDemo values(); Query OK, 1 row affected (0.04 sec)We can display a record with the ... Read More

Difference between localhost and 127.0.0.1?

Kiran Kumar Panigrahi
Updated on 01-Dec-2022 08:30:38

6K+ Views

On almost every machine, the localhost and 127.0.0.1 are functionally the same. But, they are not exactly the same. This article is meant for explain the important differences between localhost and 127.0.01. What is Localhost? "localhost" is the machine name or IP address of the host server. You can think of it as the domain name for "127.0.0.1". The localhost allows a network connection to loop back on itself. It is a communication port that is connected to the local server. It helps us in spoofing the network connections when such a network does not exist. We tend to use ... Read More

What is the difference between MySQL stored procedure and function?

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

1K+ Views

Stored Procedure In MySQL, a stored procedure can be called with the help of call statement. A stored procedure returns more than one value. A stored procedure returns 0 by default. It cannot be used in SQL query and is based on precompile. Function A function can be called inside the statement. It can return a value with the help of return statement and it returns only one value. A function returns any single value, which can be a table. It can be used in SQL query and isn’t based on precompile.

Updating a MySQL table with values from another table?

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

9K+ Views

We can update another table with the help of inner join. Let us create two tables. Creating a table mysql> CREATE table tblFirst -> ( -> id int, -> name varchar(100) -> ); Query OK, 0 rows affected (0.48 sec) Inserting records mysql> INSERT into tblFirst values(1, 'John'); Query OK, 1 row affected (0.17 sec) mysql> INSERT into tblFirst values(2, 'Bob'); Query OK, 1 row affected (0.26 sec) mysql> INSERT into tblFirst values(3, 'David'); Query OK, 1 row affected (0.20 sec) Displaying ... Read More

Advertisements