Вы находитесь на странице: 1из 2

TRANSLATE

Search w3schools.com HOME HTML C SS XML JAVASC RIPT ASP PHP SQL MORE...
REFERENCES | EXAMPLES | FO RUM

Search
| ABO UT

SQL Basic
SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL HOME Intro Syntax Select Distinct W here And & Or Order By Insert Update Delete

SQL Joins
Previous Next Chapter
SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables.

WEB HOSTING Best Web Hosting PHP MySQL Hosting Best Hosting C oupons UK Reseller Hosting C loud Hosting Top Web Hosting $3.98 Unlimited Hosting Premium Website Design WEB BUILDING Download XML Editor FREE Website BUILDER C REATE HTML Websites EASY WEBSITE BUILDER W3SCHOOLS EXAMS

SQL JOIN
The JOIN keyw ord is used in an SQL statement to query data from tw o or more tables, based on a relationship betw een certain columns in these tables. Tables in a database are often related to each other w ith keys. A primary key is a column (or a combination of columns) w ith a unique value for each row . Each primary key value must be unique w ithin the table. The purpose is to bind data together, across tables, w ithout repeating all of the data in every table. Look at the "Persons" table: P_Id 1 2 3 LastName Hansen Svendson Pettersen FirstName Ola Tove Kari Address Timoteivn 10 Borgvn 23 Storgt 20 City Sandnes Sandnes Stavanger

SQL Demo
SQL Try It

SQL Advanced
SQL Top SQL Like SQL W ildcards SQL In SQL Betw een SQL Alias SQL Joins SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL Union SQL Select Into SQL Create DB SQL Create Table SQL Constraints SQL Not Null SQL Unique SQL Primary Key SQL Foreign Key SQL Check SQL Default SQL Create Index SQL Drop SQL Alter SQL Increment SQL View s SQL Dates SQL Nulls SQL isnull() SQL Data Types

Get C ertified in: HTML, C SS, JavaScript, XML, PHP, and ASP W3SCHOOLS BOOKS New Books: HTML, C SS JavaScript, and Ajax STATISTICS

Note that the "P_Id" column is the primary key in the "Persons" table. This means that no tw o row s can have the same P_Id. The P_Id distinguishes tw o persons even if they have the same name. Next, w e have the "Orders" table: O_Id 1 2 3 4 5 OrderNo 77895 44678 22456 24562 34764 P_Id 3 3 1 1 15

Browser Statistics Browser OS Browser Display SHARE THIS PAGE Share with

Note that the "O_Id" column is the primary key in the "Orders" table and that the "P_Id" column refers to the persons in the "Persons" table w ithout using their names. Notice that the relationship betw een the tw o tables above is the "P_Id" column.

SQL Functions
SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL Functions avg() count() first() last() max() min() sum() Group By Having ucase() lcase() mid() len() round() now () format()

Different SQL JOINs


Before w e continue w ith examples, w e w ill list the types of JOIN you can use, and the differences betw een them. JOIN: Return row s w hen there is at least one match in both tables LEFT JOIN: Return all row s from the left table, even if there are no matches in the right table RIGHT JOIN: Return all row s from the right table, even if there are no matches in the left table FULL JOIN: Return row s w hen there is a match in one of the tables

Previous

Next Chapter

14,336,250 Sites Built with Wix. Create yours now!


Design and publish a professional and beautiful HTML w ebsite for free! Enjoy total design control, eCommerce features and superior search engine results, w hile saving tons of money.

SQL Quick Ref

converted by Web2PDFConvert.com

SQL Hosting SQL Summary

Award-winning XML Tools: Altova MissionKit

SQL Quiz
SQL Quiz The Altova MissionKit is an integrated suite of tools ideal for: XML development Web & Web services development Data mapping & integration Rendering & publishing XML & database data XBRL validation, taxonomy editing, transformation & rendering Chart & report generation for XML & XBRL The MissionKit for XML Developers includes XMLSpy - the industry-leading XML editor; MapForce - a graphical data mapping, conversion, and integration tool; StyleVision - a visual XSLT stylesheet and report designer; DiffDog - an XMLaw are diff/merge tool; and 2 additional tools. Try all 6 products free for 30 days! Download a fully-functional free trial

Try it now!

www.FullSail.edu

Ads by Google

REPO RT ERRO R HO | ME TO | P PRINT | FO | RUM A|BO UT

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2012 by Refsnes Data. All Rights Reserved.

converted by Web2PDFConvert.com

Вам также может понравиться