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 22-06-2009
Member
 
Join Date: May 2008
Posts: 30
problem with subquery in MySQL

Hi,

I am new to MySQL & I have been working with MsAccess so I want to pass this query in MySQL but I am not sure. So please help.
This is my query:
Code:
Select * from Employees where ID="Select Max(ID) from salary";
Now the problem is can we pass a subquery in MySQL? How?
Reply With Quote
  #2  
Old 22-06-2009
Member
 
Join Date: May 2008
Posts: 68
Re: problem with subquery in MySQL

Yes MySQL supports subqueries.
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.
What version of MySQL is running on your server? Older versions don't support subqueries, at all.
Here is what you need to do.

Code:
SELECT * FROM table1 WHERE column1 = (SELECT column1 FROM table2);
learn SubQueries:
Reply With Quote
  #3  
Old 22-06-2009
Member
 
Join Date: May 2008
Posts: 72
Re: problem with subquery in MySQL

Hey this is what happened with me when I had started with MySql.
but I had different problems since I needed to do inner & outer joins which was more complex.
The guide is really helpful. All the best.
I have a question which is related with subqueries.
I want to ask if I have multiple tables & a complex subquery then is there anyway to get rid of subqueries?
Reply With Quote
  #4  
Old 22-06-2009
Member
 
Join Date: May 2008
Posts: 35
Re: problem with subquery in MySQL

I don't think there is any alternative to subqueries. & why you want to avoid it?
I think if you put your problem in detail here with the code then it will be a lot helpful to guide you.
Thanks.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "problem with subquery in MySQL"
Thread Thread Starter Forum Replies Last Post
MySQL 9.04 to 9.10 problem Flacos Operating Systems 5 24-04-2010 05:31 AM
Mysql problem GlassFish Software Development 5 15-12-2009 02:07 PM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
Implement subquery for a database kelfro Software Development 3 06-11-2009 10:28 PM
Problem connecting to mysql Damodar Software Development 3 25-02-2009 03:16 PM


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