Anyone familiar with SQL and relational databases has met many connection types. In short, join combines the content of two tables into a virtual table or recordset. If the data table is effectively normalized, you may often select specific information from a table and then select association information from another table. To do this, you need a simple "equijoin )".
To understand the actual connection operations, let's assume that some software records are stored in the memory of a database. A table (Software) contains the name of the Software product, the Software version, and other related details: running image004.gif]
Another table (Releases) stores information about the software release history, including the release date and status (such as the test version, current version, and outdated version): paiimage005.gif]
The table above also contains a column that points to the ID number used in the software table. Therefore, by using this index software table, you will know that the software_ID in the release table is equal to 2.
You use the join combination information, so you do not need to go back and forth between two tables. However, in addition to combining information, you can also combine relevant information through connections. In this way, as long as the software_ID in the publishing table matches the ID in the software table, you can put the matching information together in a record.
The code is as follows:
SQL = "SELECT * FROM Software, Releases WHERE software. ID = releases. softwareID"
After carefully analyzing the preceding statements, we first notice that the two tables are listed behind the FROM table. Based on the connections used, you may also find that the syntax will change (or the connection type will change) in the future, but the above syntax is the most basic, displays how data is selected. The WHERE clause is used to compare specific ID values. The ID column exists in the Software table. Similarly, the Releases table contains a software_ID column. To clarify the values you want to compare in the WHERE clause, you use the table name as the prefix, followed by a dot (.).
The following is the result after connecting the selected data: export image006.gif]
Note: When creating a connection, you must carefully consider the data columns. The above code uses the * wildcard to attract readers to the rest of the SELECT code line. However, as you can see in the preceding figure, you cannot select the softwareID column because it is not added as part of the recordset. It is used by the WHERE clause.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service