MySQLi Articles

Page 55 of 341

How can we create a MySQL view by selecting some range of values from a base table?

Kumar Varma
Kumar Varma
Updated on 22-Jun-2020 245 Views

As we know that MySQL BETWEEN operator can be used to select values from some range of values. We can use BETWEEN operator along with views to select some range of values from the base table. To understand this concept we are using the base 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     ...

Read More

Which PHP functions are used in the PHP script to fetch data from an existing MySQL table?

Nikitha N
Nikitha N
Updated on 22-Jun-2020 228 Views

PHP uses following functions to fetch data from an existing MySQL table −mysql_query() functionThis function is used in PHP script to fetch data from an existing MySQL table. This function takes two parameters and returns TRUE on success or FALSE on failure. Its syntax is as follows −Syntaxbool mysql_query( sql, connection );Followings are the parameters used in this function −S. No.Parameter & Description1.SqlRequired - SQL query to fetch data from an existing MySQL table2.connectionOptional - if not specified, then the last opened connection by mysql_connect will be used.mysql_fetch_array() functionThis is another function which is used in PHP script while fetching ...

Read More

How can we display all the records from MySQL table with the help of PHP script?

Priya Pallavi
Priya Pallavi
Updated on 22-Jun-2020 1K+ Views

To illustrate this we are fetching all the records from a table named ‘Tutorials_tbl’ with the help of PHP script that uses mysql_query() and mysql_fetch_array() function in the following example −

Read More

How can we create a MySQL view with a subquery?

Sharon Christine
Sharon Christine
Updated on 22-Jun-2020 2K+ Views

To illustrate the making of MySQL view with subquery we are using the following data from the table ‘Cars’ −mysql> select * from cars; +------+--------------+---------+ | ID   | Name         | Price   | +------+--------------+---------+ |    1 | Nexa         | 750000  | |    2 | Maruti Swift | 450000  | |    3 | BMW          | 4450000 | |    4 | VOLVO        | 2250000 | |    5 | Alto         | 250000  | |    6 | Skoda ...

Read More

Where MySQL views can be inconsistent and how can we ensure their consistency?

Rama Giri
Rama Giri
Updated on 22-Jun-2020 257 Views

In case of updateable views, it is quite possible that we update the data that is not visible through the view because we create a view to revealing only the partial data of a table. Such kind of updates makes the view inconsistent. We can ensure the consistency of views by using WITH CHECK OPTION while creating or modifying the views. Although WITH CHECK OPTION clause is an optional part of CREATE VIEW statement but it is very useful to make views consistent.Basically, the WITH CHECK OPTION clause prevents us from updating or inserting the rows which are not visible ...

Read More

How can I create a MySQL view that takes the values from a table based on some condition(s)?

Vikyath Ram
Vikyath Ram
Updated on 22-Jun-2020 305 Views

If we want to create a view that takes the values from a table based on some particular condition(s) then we have to use WHERE clause while creating the view. The values depending upon the WHERE clause will be stored in view. The syntax of creating a MySQL view with WHERE clause can be as follows −SyntaxCreate View view_name AS Select_statements FROM table WHERE condition(s);ExampleTo illustrate the above concept, we are using the following data from table ‘Student_info’ −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101 ...

Read More

How can we see the metadata of a view(s) stored in a particular MySQL database?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 22-Jun-2020 281 Views

The INFORMATION_SCHEMA database has a VIEWS table that contains view metadata i.e. data about views. To illustrate it we are taking the example of a view named ‘Info’.ExampleThe following query will show the metadata of a view named ‘Info’ −mysql> SELECT * from INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'Info' AND TABLE_SCHEMA = 'query'\G *************************** 1. row *************************** TABLE_CATALOG: def  TABLE_SCHEMA: query    TABLE_NAME: info VIEW_DEFINITION:select`query`.`student_info`.`id`AS`ID`, `query`.`student_info`.`Name` AS `NAME`, `query`.`student_info`.`Subject` AS `SUBJECT`, `query`.` student_info`.`Address` AS `ADDRESS` from `query`.`student_info`         CHECK_OPTION: NONE         IS_UPDATABLE: YES              DEFINER: root@localhost       ...

Read More

How can we delete an existing MySQL table by using PHP script?

Nitya Raut
Nitya Raut
Updated on 22-Jun-2020 283 Views

As we know that PHP provides us the function named mysql_query to delete an existing MySQL table.ExampleTo illustrate this we are deleting a table named ‘Tutorials_tbl’ with the help of PHP script in the following example −           Creating MySQL Tables                  

Read More

How can we get the structure of a MySQL view as we can get the structure of a MySQL table?

Arjun Thakur
Arjun Thakur
Updated on 22-Jun-2020 493 Views

As we know that views are a type of virtual tables and are a composition of tables too hence we can use the same query to get the structure of a view which we use to get the structure of a table. In other words, we can use DESCRIBE statement to get the structure of a MySQL view. Its syntax would be as follows −SyntaxDESCRIBE view_name;Here, view_name is the name of the view of which we want to get the structure.ExampleSuppose we want to get the structure of a view named ‘Info’ then it can be done with the help, of the following query ...

Read More

How can we fetch all the data from MySQL table by using mysql_fetch_array() function, returning an array with the numeric index, in PHP script?

Prabhas
Prabhas
Updated on 22-Jun-2020 788 Views

The function mysql_fetch_array() will return an array with the numeric index if we use the constant MYSQL_NUM as the second argument to it. To illustrate it we are having the following example −ExampleIn this example, we are fetching all the records from a table named ‘Tutorials_tbl’ with the help of PHP script that uses mysql_fetch_array() function using MYSQL_NUM as the second argument in the following example −

Read More
Showing 541–550 of 3,404 articles
« Prev 1 53 54 55 56 57 341 Next »
Advertisements