Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Subqueries In Mysql, Using subqueries in MySQL. Very helpful.
cybernaut
post Feb 16 2008, 03:18 AM
Post #1


Newbie [ Level 2 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
richard_site
post Mar 31 2008, 06:45 PM
Post #2


Newbie [ Level 1 ]
Group Icon

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


Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. MySQL - Trouble With Bulk Insert Statements(3)
  2. MySQL Realtime Replication(4)
  3. Recover Tables From A MySQL .frm File(8)
  4. Mirror My MySQL Database To Another Mysql Server(4)
  5. How To Connect MySQL With Flash?(8)
  6. MySQL Output Database Question(18)
  7. MySQL, Multiple Tables(24)
  8. Is It A Good Practice To Store Image Or Other Binary Files Directly In A Mysql Database(4)
  9. Navcat For MySQL(8)
  10. Permission Problem With Mysql Database Creation(8)
  11. Mysql And Php(15)
  12. Problems With Php Saving Data Into Mysql(6)
  13. Login System Using A Mysql Db(5)
  14. Oracle Vs. Mysql Vs. Postgresql(9)
  15. Apache Php With Mysql On Windows [solved](9)
  1. Not Understanding Mysql(4)
  2. Mysql Script Help(3)
  3. Mysql - So Hard(14)
  4. Mysql Problem(1)
  5. Sun Bought Mysql(6)
  6. Mysql Backup With Another Address?(4)
  7. I Have An Error With My Mysql Connection(7)
  8. Mysql And User File_priv(0)
  9. Mysql Database Management(1)
  10. Mysql Database Entry By Excel Sheets(2)
  11. Mysql On Computer(9)
  12. Any Website Provide Free Host Mysql Host?(4)
  13. Mysql Multiple Tables(1)


 



- Lo-Fi Version Time is now: 5th September 2008 - 05:56 AM