| | |
combine three tables
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Check out the Referring to Two Tables example
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
this is one example:
this is based on joins...
see this for reference:
http://www.tizag.com/mysqlTutorial/mysqljoins.php
this is based on joins...
mysql Syntax (Toggle Plain Text)
CREATE TABLE Articles ( ArticleID SMALLINT NOT NULL PRIMARY KEY, ArticleTitle VARCHAR(60) NOT NULL, Copyright YEAR NOT NULL ) ENGINE=INNODB; INSERT INTO Articles VALUES (12786, 'How write a paper', 1934), (13331, 'Publish a paper', 1919), (14356, 'Sell a paper', 1966), (15729, 'Buy a paper', 1932), (16284, 'Conferences', 1996), (17695, 'Journal', 1980), (19264, 'Information', 1992), (19354, 'AI', 1993); CREATE TABLE Authors ( AuthID SMALLINT NOT NULL PRIMARY KEY, AuthorFirstName VARCHAR(20), AuthorMiddleName VARCHAR(20), AuthorLastName VARCHAR(20) ) ENGINE=INNODB; INSERT INTO Authors VALUES (1006, 'Henry', 'S.', 'Thompson'), (1007, 'Jason', 'Carol', 'Oak'), (1008, 'James', NULL, 'Elk'), (1009, 'Tom', 'M', 'Ride'), (1010, 'Jack', 'K', 'Ken'), (1011, 'Mary', 'G.', 'Lee'), (1012, 'Annie', NULL, 'Peng'), (1013, 'Alan', NULL, 'Wang'), (1014, 'Nelson', NULL, 'Yin'); CREATE TABLE AuthorArticle ( AuthID SMALLINT NOT NULL, ArticleID SMALLINT NOT NULL, PRIMARY KEY (AuthID, ArticleID), FOREIGN KEY (AuthID) REFERENCES Authors (AuthID), FOREIGN KEY (ArticleID) REFERENCES Articles (ArticleID) ) ENGINE=INNODB; INSERT INTO AuthorArticle VALUES (1006, 14356), (1008, 15729), (1009, 12786), (1010, 17695), (1011, 15729), (1012, 19264), (1012, 19354), (1014, 16284); SELECT STRAIGHT_JOIN ArticleTitle, Copyright, CONCAT_WS(' ', AuthorFirstName, AuthorMiddleName, AuthorLastName) AS Author FROM Articles AS b, AuthorArticle AS ab, Authors AS a WHERE b.ArticleID=ab.ArticleID AND ab.AuthID=a.AuthID AND Copyright<1980 ORDER BY ArticleTitle;
http://www.tizag.com/mysqlTutorial/mysqljoins.php
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
![]() |
Similar Threads
- Unwanted Blank Spaces in Banner (HTML and CSS)
- Optimizing tables to compare bilions of rows. How? (Database Design)
- how to get the difference between the data of the two files (Visual Basic 4 / 5 / 6)
- Datas from different tables in one crystal report.. (Visual Basic 4 / 5 / 6)
- Searching for a record in multiple tables (VB.NET)
- Any way to combine two datasources into one recordset? (ASP)
- Query multiple tables? (MySQL)
- Please check 4 me ? (Website Reviews)
Other Threads in the MySQL Forum
- Previous Thread: insert checkbox values to database
- Next Thread: In Mysql Storing and retriving the image with asp.net
Views: 1107 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for MySQL
"use" 1 agplv3 alfresco amazon api artisticlicense breathalyzer camparingtocolumns changingprices cmg contentmanagement count court crm data database design developer development drupal ec2 eliminate email enter enterprise error eudora facebook form foss gartner gnu government gpl greenit groklaw groupware images innerjoins insert ip joebrockmeier join journalism keyword keywords laptop law legal license licensing linux maintenance managing matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource operand oracle pdf penelope php priceupdating referencedesign remove reorderingcolumns resultset saas select sharepoint sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency update virtualization






