Found 4219 Articles for MySQLi

Which PHP function is used to establish MySQL database connection using PHP script?

mkotla
Updated on 22-Jun-2020 13:23:44

137 Views

PHP provides mysql_connect() function to open a database connection. This function takes five parameters and returns a MySQL link identifier on success or FALSE on failure. Its syntax is as follows −Syntaxconnection mysql_connect(server, user, passwd, new_link, client_flag);Following table give us the parameters used in the syntax above −Sr.NoParameter & Description1ServerOptional − The host name running the database server. If not specified, then the default value will be localhost:33062UserOptional − The username accessing the database. If not specified, then the default will be the name of the user that owns the server process3PasswdOptional − The password of the user accessing the ... Read More

How can MySQL work with PHP programming language?

Giri Raju
Updated on 20-Dec-2019 06:25:34

571 Views

MySQL works very well in combination with various programming languages like PERL, C, C++, JAVA, and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.PHP provides various functions to access the MySQL database and to manipulate the data records inside the MySQL database. You would require calling the PHP functions in the same way you call any other PHP function.The PHP functions for use with MySQL have the following general format –mysql_function(value, value, ...);The second part of the function name is specific to the function, usually a word that describes what ... Read More

How can we see the list of views stored in a particular MySQL database?

Chandu yadav
Updated on 17-Feb-2020 08:54:10

108 Views

With the help of following queries,  we can see the list of views stored in a particular database. We are using the database named ‘query’ here.mysql> SELECT TABLE_NAME FROM information_schema.`TABLES` WHERE TABLE_TYPE LIKE'view' AND TABLE_SCHEMA LIKE 'query'; +-----------------------------+ | TABLE_NAME                  | +-----------------------------+ | customer_view               | | first_view                  | | info                        | | info_less                   | | view_detail   ... Read More

How can we modify the definition of a MySQL view without dropping it?

Kumar Varma
Updated on 22-Jun-2020 13:31:43

115 Views

With the help of ALTER VIEW statement, we can modify the definition of MySQL view. In this case, we do not need to drop it. The syntax would be as follows −SyntaxALTER VIEW view_name AS SELECT column1, column2… FROM table WHERE conditions;ExampleTo illustrate it we are modifying the definition of a view named ‘Info’ which have the following data −mysql> Select * from Info; +------+---------+------------+ | Id   | Name    | Subject    | +------+---------+------------+ | 101  | YashPal | History    | | 105  | Gaurav  | Literature | | 125  | Raman   | Computers  | | ... Read More

After updating any value in a particular view, will MySQL updates the same in the base table and its associated views (if any)?

Moumita
Updated on 22-Jun-2020 13:30:40

27 Views

Yes, MySQL will update the value, if it is updated in a view, in the base table as well as in its associated views. To illustrate it we are taking the example of table Student_info having the following data −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | Literature | | 125  | Raman   | Shimla     | Computers  | | NULL | Ram     | Jhansi   ... Read More

How can we update any value in MySQL view as we can update the values in MySQL table?

karthikeya Boyini
Updated on 22-Jun-2020 13:32:30

370 Views

As we know that with the help of UPDATE statement we can update the values in MySQL table and in the similar way we can update the values in MySQL views. The syntax of UPDATE statement would be the same except at the place of table name we have to provide the name of the view. We are taking the data as follows from a view named ‘Info’ to illustrate the above concept −mysql> Select * from Info; +------+---------+------------+ | Id   | Name    | Subject    | +------+---------+------------+ | 101  | YashPal | History    | | 105 ... Read More

How can we use MySQL REPLACE statement to prevent of insertion of duplicate data?

varun
Updated on 22-Jun-2020 13:26:43

336 Views

We can use the REPLACE statement while inserting the data to prevent the insertion of duplicate data. If we will use the REPLACE command rather than the INSERT command then if the record is new, it is inserted just as with INSERT else if it is a duplicate, the new record replaces the old one.SyntaxREPLACE INTO table_name(…)Here,  table_name is the name of the table in which we want to insert the values.ExampleIn this example we will insert the data with the help of REPLACE statement as follows −mysql> REPLACE INTO person_tbl (last_name, first_name)     -> VALUES( 'Ajay', 'Kumar'); Query OK, ... Read More

How can we get the total number of rows affected by MySQL query?

Prabhas
Updated on 22-Jun-2020 13:27:10

3K+ Views

MySQL ROW_COUNT() can be used to get the total number of rows affected by MySQL query. To illustrate it we are creating a procedure with the help of which we can insert records in a table and it will show us how many rows have been affected.Examplemysql> Delimiter // mysql> CREATE PROCEDURE `query`.`row_cnt` (IN command VarChar(60000))     -> BEGIN     ->    SET @query = command;     ->    PREPARE stmt FROM @query;     ->    EXECUTE stmt;     ->    SELECT ROW_COUNT() AS 'Affected rows';     -> END // Query OK, 0 rows ... Read More

How can I delete MySQL temporary table?

V Jyothi
Updated on 22-Jun-2020 13:07:23

453 Views

As we know that MySQL temporary table would be deleted if the current session is terminated. But of still in between the session we want to delete the temporary table than with the help of the DROP statement we can delete the temporary table. It can be understood with the help of the following example −ExampleIn this example, we are deleting the temporary table named ‘SalesSummary’ −mysql> DROP TABLE SalesSummary; Query OK, 0 rows affected (0.00 sec)The above query will delete the table and it can be confirmed from the query below −mysql> Select * from SalesSummary; ERROR 1146 (42S02): ... Read More

What happens to MySQL temporary tables if MySQL session is ended?

seetha
Updated on 30-Jul-2019 22:30:21

86 Views

Temporary table would be deleted if MySQL session terminates. After login again, on issuing the SELECT command we will find no data available in the database. Even our temporary table will not exist.

Advertisements