ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------1 Paul 32 California 20000.02 Allen 25 Texas 15000.03 Teddy 23 Norway 20000.04 Mark 25 Rich-Mond 65000.05 David 27 Texas 85000.06 Kim 22 South-Hall 45000.07 James 24 Houston 10000.0
CREATE TABLE DEPARTMENT( ID INT PRIMARY KEY NOT NULL, DEPT CHAR(50) NOT NULL, EMP_ID INT NOT NULL);
INSERT INTO DEPARTMENT (ID, DEPT, EMP_ID)VALUES (1, 'IT Billing', 1 );INSERT INTO DEPARTMENT (ID, DEPT, EMP_ID)VALUES (2, 'Engineering', 2 );INSERT INTO DEPARTMENT (ID, DEPT, EMP_ID)VALUES (3, 'Finance', 7 );
ID DEPT EMP_ID---------- ---------- ----------1 IT Billing 12 Engineerin 23 Finance 7
SELECT ... FROM table1 CROSS JOIN table2 ...
sqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY CROSS JOIN DEPARTMENT;
EMP_ID NAME DEPT---------- ---------- ----------1 Paul IT Billing2 Paul Engineerin7 Paul Finance1 Allen IT Billing2 Allen Engineerin7 Allen Finance1 Teddy IT Billing2 Teddy Engineerin7 Teddy Finance1 Mark IT Billing2 Mark Engineerin7 Mark Finance1 David IT Billing2 David Engineerin7 David Finance1 Kim IT Billing2 Kim Engineerin7 Kim Finance1 James IT Billing2 James Engineerin7 James Finance
SELECT ... FROM table1 [INNER] JOIN table2 ON conditional_expression ...
SELECT ... FROM table1 JOIN table2 USING ( column1 ,... ) ...
SELECT ... FROM table1 NATURAL JOIN table2...
sqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY INNER JOIN DEPARTMENT ON COMPANY.ID = DEPARTMENT.EMP_ID;
EMP_ID NAME DEPT---------- ---------- ----------1 Paul IT Billing2 Allen Engineerin7 James Finance
SELECT ... FROM table1 LEFT OUTER JOIN table2 ON conditional_expression ...
SELECT ... FROM table1 LEFT OUTER JOIN table2 USING ( column1 ,... ) ...
sqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY LEFT OUTER JOIN DEPARTMENT ON COMPANY.ID = DEPARTMENT.EMP_ID;
EMP_ID NAME DEPT---------- ---------- ----------1 Paul IT Billing2 Allen Engineerin Teddy Mark David Kim7 James Finance
Nguồn tin: vncoder.vn
Những tin mới hơn
Những tin cũ hơn
- Click vào nút hiển thị ngày trong tuần hoặc tháng âm lịch để xem chi tiết
- Màu đỏ: Ngày tốt
- Xanh lá: Đầu tháng âm lịch
- Màu vàng: Ngày hiện tại