Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-08-2009
Member
 
Join Date: Aug 2008
Posts: 90
About mysql table subqueries

Hello,

Hey guys am not very much sure about the mysql table subqueries.
If you guys can just poing me to a tutorial on mysql table subqueries? Is subqueries really helpful?

Thanks in advance.
Reply With Quote
  #2  
Old 04-08-2009
Member
 
Join Date: May 2008
Posts: 24
Re: About mysql table subqueries

Subqueries in MySQL

A subquery is, in essence, a SQL statement that is most often used as part of another SELECT statement. Sub queries are used in order to achieve very complex searches and complex reports.

A subquery is, in essence, a SELECT statement that is most often used as part of another SELECT statement, but could also be used with an INSERT, UPDATE, or DELETE and other statements. Subqueries are used in order to achieve very complex searches and complex reports, as well as for various optimizations. You can use a subquery in the FROM clause of a SELECT to allow you to have essentially any number of GROUP BY clauses to further and further refine your result.

The Simplest of Simple

Well, the obvious first thing to take a look at, is the simplest possible subquery you could issue:

Code:
SELECT (SELECT 1);

  +------------+
  | (SELECT 1) |
  +------------+
  |          1 |
  +------------+
It's possible to nest subqueries, and pass values through any number of levels, for instance:

Code:
SELECT (SELECT (SELECT 1));

  +---------------------+
  | (SELECT (SELECT 1)) |
  +---------------------+
  |                   1 |
  +---------------------+
eg:

Code:
SELECT name, headofstate
  FROM Country
  WHERE code=(SELECT "SWE");

  +--------+-----------------+
  | name   | headofstate     |
  +--------+-----------------+
  | Sweden | Carl XVI Gustaf |
  +--------+-----------------+
Reply With Quote
  #3  
Old 04-08-2009
Member
 
Join Date: Aug 2008
Posts: 90
Re: About mysql table subqueries

Thanks for the prompt reply.

Ill definitely have a look at the tutorial.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "About mysql table subqueries"
Thread Thread Starter Forum Replies Last Post
Subqueries used in MySQL MacKenze Software Development 2 04-01-2011 01:59 AM
What are the Table Types in MySQL? Dino M Software Development 7 29-10-2010 05:18 PM
Structure of Table in MySQL Eleeazar Software Development 4 06-11-2009 10:57 PM
How to Insert data into MySQL table Mahendra varma Software Development 4 04-10-2009 04:42 AM
How to repair MySQL table? Suzane Software Development 3 05-09-2009 11:50 AM


All times are GMT +5.5. The time now is 01:15 PM.