TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   problem with subquery in MySQL (http://forums.techarena.in/software-development/1201540.htm)

nonose 22-06-2009 12:52 PM

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?

Andrzej 22-06-2009 12:58 PM

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:

Honorata 22-06-2009 01:06 PM

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?

beatnik_abx 22-06-2009 01:08 PM

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.


All times are GMT +5.5. The time now is 12:23 AM.