Found 4219 Articles for MySQLi

How can we use a combination of logical operators while creating MySQL views?

Monica Mona
Updated on 22-Jun-2020 13:47:56

99 Views

MySQL views can be created by using a combination of logical operators like AND, OR, and NOT. It can be illustrated with the help of following examples −Examplemysql> Create or Replace View Info AS select ID, Name, Address , Subject FROM Student_info WHERE (Subject = 'Computers' AND ADDRESS = 'Delhi') OR (Subject = 'History' AND Address = 'Amritsar'); Query OK, 0 rows affected (0.11 sec) mysql> Select * from Info; +------+-------+---------+-----------+ | ID   | Name  | Address | Subject   | +------+-------+---------+-----------+ | 133  | Mohan | Delhi   | Computers | +------+-------+---------+-----------+ 1 row in set (0.00 sec)

How can we write PHP script to release cursor memory associated with MySQL result?

usharani
Updated on 22-Jun-2020 14:03:17

196 Views

As we know that PHP uses the msql_free_result() function to release cursor memory associated with MySQL result. To illustrate it we are having the following example −ExampleIn this example, we are writing the following PHP script that will release the memory after fetching the records from a table named ‘Tutorials_tbl’.

Which PHP function is used to release cursor memory associated with MySQL result?

varun
Updated on 22-Jun-2020 14:06:01

167 Views

PHP uses mysql_free_result() function to release the cursor memory associated with MySQL result. It returns no value.SyntaxMysql_free_result(result);Followings are the parameters used in this function −Sr.NoParameter & Description1ResultRequired- Specifies a result set identifier returned by mysql_query(), mysql_store_result() or mysql_use_result()

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

Vikyath Ram
Updated on 22-Jun-2020 13:48:48

175 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 use logical operators while creating MySQL views?

Chandu yadav
Updated on 22-Jun-2020 14:05:21

136 Views

MySQL views can be created by using logical operators like AND, OR, and NOT. It can be illustrated with the help of following examples −Views with AND operatorAs we know that logical AND operator compares two expressions and returns true if both the expressions are true. In the following example,  we are creating a view which has the conditions based on ‘AND’ operator.ExampleThe base table is Student_info having the following data −mysql> Select * from Student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History ... Read More

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

Rama Giri
Updated on 22-Jun-2020 13:50:38

106 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 we create a MySQL view with a subquery?

Sharon Christine
Updated on 22-Jun-2020 13:51:28

1K+ 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

How can we modify a MySQL view with CREATE OR REPLACE VIEW statement?

Ayyan
Updated on 22-Jun-2020 13:40:10

339 Views

As we know that we can modify a view by using ALTER VIEW statement but other than that we can also use CREATE OR REPLACE VIEW to modify an existing view. The concept is simple as MySQL simply modifies the view if it already exists otherwise a new view would be created. Following is the syntax of it −SyntaxCREATE OR REPLACE VIEW view_name AS Select_statements FROM table;Examplemysql> Create OR Replace VIEW Info AS Select Id, Name, Address, Subject from student_info WHERE Subject = 'Computers'; Query OK, 0 rows affected (0.46 sec)The above query will create or replace a view ‘Info’. ... Read More

How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?

Samual Sam
Updated on 22-Jun-2020 13:38:47

223 Views

As we know that views are a type of virtual tables and are the composition of tables too hence we can use the same query to list all the columns of a MySQL view as we can list the columns of a MySQL table. In other words, we can use SHOW FULL COLUMNS statement to get the structure of a MySQL view. Its syntax would be as follows −SyntaxSHOW FULL COLUMNS FROM View_name;Here view_name is the name of the view from which we want to get the list of columns.ExampleSuppose if we want to get a list of columns of ... Read More

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

Jai Janardhan
Updated on 22-Jun-2020 13:42:31

264 Views

As we know that views are a type of virtual tables and are the composition of tables too hence we can use the same query to get the definition of a view which we use to get the definition of a table. In other words, we can use SHOW CREATE statement to get the definition of a MySQL view. Its syntax would be as follows −SyntaxSHOW CREATE VIEW view_name;Here view_name is the name of the view of which we want to get the definition.ExampleThe following query will give the definition of a view named ‘info’ −mysql> Show Create View Info\G ... Read More

Advertisements