Results 1 to 4 of 4

Thread: problem with subquery in MySQL

  1. #1
    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?

  2. #2
    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:

  3. #3
    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?

  4. #4
    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.

Similar Threads

  1. MySQL 9.04 to 9.10 problem
    By Flacos in forum Operating Systems
    Replies: 5
    Last Post: 24-04-2010, 05:31 AM
  2. Mysql problem
    By GlassFish in forum Software Development
    Replies: 5
    Last Post: 15-12-2009, 02:07 PM
  3. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  4. Implement subquery for a database
    By kelfro in forum Software Development
    Replies: 3
    Last Post: 06-11-2009, 10:28 PM
  5. Problem connecting to mysql
    By Damodar in forum Software Development
    Replies: 3
    Last Post: 25-02-2009, 03:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,992,842.72380 seconds with 16 queries