Results 1 to 6 of 6
  1. #1
    Join Date
    May 2003
    Location
    Belgrade, Serbia
    Posts
    1

    Exclamation Unanswered: is it possible SELECT * FROM ( SELECT * FROM ...

    This is normal in MS SQL Server, but when I've tried in MySQL

    If it is not possible, what should I've do, do I have to create temporary table every time I wish to do this.

  2. #2
    Join Date
    May 2002
    Location
    Vancouver Canada
    Posts
    26
    There are always other ways. I never use temporary tables. Just have PHP do any extra little bits of work.

  3. #3
    Join Date
    Nov 2002
    Posts
    8
    Not everybody is using PHP !
    Nested select queries are not included in MySQL but theres some other ways. Give a proper example what u wanna do.

  4. #4
    Join Date
    Jun 2003
    Posts
    1

    exemple of imbricated select

    Originally posted by kristoph
    Not everybody is using PHP !
    Nested select queries are not included in MySQL but theres some other ways. Give a proper example what u wanna do.
    I have a similar problem with imbricated select. I made this in MS-Access:

    SELECT code, proposals.name, propdoc.type
    FROM proposals, documents AS propdoc
    WHERE propdoc.attachto = proposals.propid and
    propdoc.type = "Proposals" and
    (
    SELECT Count(documents.docid)
    FROM documents
    WHERE documents.attachto = propdoc.docid
    ) = 0
    ORDER BY propdoc.type;

    I try to switch it like this to work in mySQL:

    SELECT code, proposals.name, propdoc.type, count(documents.docid) as cpt
    FROM proposals, documents AS propdoc, documents
    WHERE propdoc.attachto = proposals.propid and
    documents.attachto = propdoc.docid and
    propdoc.type = "Proposals" and
    cpt = 0
    ORDER BY propdoc.type;

    But MS-Access (which I use as a front-end to connect to a mySQL db) doesn't let me run it, because it has a part which is not part of the aggregate (the field code).

    Thank you in advance,
    thamez

  5. #5
    Join Date
    Jun 2003
    Posts
    3

    Re: is it possible SELECT * FROM ( SELECT * FROM ...

    Originally posted by smatic
    This is normal in MS SQL Server, but when I've tried in MySQL

    If it is not possible, what should I've do, do I have to create temporary table every time I wish to do this.
    hi,

    from version 4.1 it is posible to do it like:

    select row1 from table where a = (select b from table2);

    bye

  6. #6
    Join Date
    Jun 2003
    Location
    Binghamton, NY
    Posts
    8
    Version 4.1 will allow this. However, you might be able to use a JOIN to get what you need

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •