Home >Database >Mysql Tutorial >Detailed introduction to mysql connection
Self-Join As mentioned earlier, one of the main reasons for using table aliases is to reference the same table more than once in a single SELECT statement. Here's an example. Suppose you discover a problem with an item (with ID DTNTR ) and want to know if other items produced by the supplier that produces it also have these problems. This query requires first finding the supplier that produces the item with ID DTNTR, and then finding other items produced by this supplier. Here is one way to solve this problem: Input: select prod_id,prod_name from products where vend_id = (select vend_id from products where prod_id = 'DTNTR'); Output: Analysis: This is the first solution, which uses sub Inquire. Internal SELECT statement
1. mysql advanced connection-self-join usage example
##Introduction: Self-Join As mentioned earlier, one of the main reasons for using table aliases is to reference the same table more than once in a single SELECT statement. Here's an example. Suppose you discover a problem with an item (with ID DTNTR ) and want to know if other items produced by the supplier that produces it also have these problems. This query requires first finding the supplier that produces the item with ID DTNTR, and then finding other items produced by this supplier.
Introduction: The processing speed of mysql's self-join is much faster than that of subqueries . Therefore, it is still necessary to learn self-connection. Ordinary sql subquery statement SELECT `id`,`bic` FROM `biao` WHERE `id`=(SELECT `id` FROM `biao` WHERE `id`='9696e'); mysql self-join sql statement SELECT `id`,`bic` FROM `biao` AS a, `b
3. MySQL Learning Footprint Record 14--Table Alias and Self-Join_MySQL
Introduction: MySQL learning footprint record 14--Table aliases and self-joins
4. MySQL creates advanced joins_MySQL
Introduction: SQL allows you to alias tables. The two main reasons for doing this are: to shorten the SQL statement; to allow the same table to be used multiple times in a single SELECT statement; and to Correspondingly, we use aliases to represent a table: Self-joining problem: Suppose we know that a product produced by a certain manufacturer has an ID of
The above is the detailed content of Detailed introduction to mysql connection. For more information, please follow other related articles on the PHP Chinese website!