|
|
|
|
![]() ![]() |
Feb 16 2008, 03:18 AM
Post
#1
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 14 Joined: 15-February 08 Member No.: 28,427 |
This method is very useful. I always use this when simple queries of linking two tables is not enough.
This method is putting a query inside a query. Example: SELECT * FROM table1 LEFT JOIN (SELECT * FROM table2 WHERE field1='id') AS subtable or joining multiple queries SELECT * FROM (SELECT * FROM table1 WHERE userid='001') AS subtable1 LEFT JOIN (SELECT * FROM table2 WHERE field1='id') AS subtable2 You can join more than two queries depending on the output you want. If someone already posted this topic here I'm sorry I don't know. |
|
|
|
Mar 31 2008, 06:45 PM
Post
#2
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 5 Joined: 27-March 08 Member No.: 29,429 |
Starting with MySQL 4.1, all subquery forms and operations that the SQL standard requires are supported, as well as a few features that are MySQL-specific.
Subqueries in MySQL http://dev.mysql.com/tech-resources/articl...ies_part_1.html MySQL 5.0 Reference Manual :: 12 SQL Statement Syntax :: 12.2 Data Manipulation Statements :: 12.2.8 Subquery Syntax http://dev.mysql.com/doc/refman/5.0/en/subqueries.html |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 24th July 2008 - 02:00 PM |