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(3)
  3. Recover Tables From A MySQL .frm File(6)
  4. Mirror My MySQL Database To Another Mysql Server(4)
  5. How To Connect MySQL With Flash?(8)
  6. MySQL, Multiple Tables(24)
  7. Is It A Good Practice To Store Image Or Other Binary Files Directly In A Mysql Database(4)
  8. Navcat For MySQL(7)
  9. Permission Problem With Mysql Database Creation(8)
  10. Mysql And Php(15)
  11. Problems With Php Saving Data Into Mysql(6)
  12. Login System Using A Mysql Db(4)
  13. Oracle Vs. Mysql Vs. Postgresql(9)
  14. Installing Mysql?(17)
  15. Mysql Query Question(3)
  1. Lost Connection To Mysql ,..., System Error: 111 In(3)
  2. Apache Php With Mysql On Windows [solved](9)
  3. Not Understanding Mysql(4)
  4. Mysql Script Help(3)
  5. Mysql - So Hard(14)
  6. Mysql Problem(1)
  7. Sun Bought Mysql(6)
  8. Mysql Backup With Another Address?(4)
  9. I Have An Error With My Mysql Connection(7)
  10. Mysql And User File_priv(0)
  11. Mysql Database Management(1)
  12. Mysql Database Entry By Excel Sheets(2)
  13. Mysql On Computer(9)


 



- Lo-Fi Version Time is now: 24th July 2008 - 02:00 PM