Professional Web Applications Themes

nested subquery in FROM clause - MySQL

Hi all, I am using MySQL 5.0.26-community-nt, and was excited about possibility to use nested queries in the FROM clause of SELECT statement. It says in the doentation, section 13.2.8.8 (the paragraph one before the last) that nested SELECT clauses can return tables. I thought it means that table names can be returned as well. Say, one has many tables named as t_0001, t_0002, ..., t_9999. There is also a table called main, such that it has fields (id int, tname varchar(7)). I am wondering is there any way to do, for example DESCRIBE (SELECT tname FROM main WHERE id ...

  1. #1

    Default nested subquery in FROM clause

    Hi all,

    I am using MySQL 5.0.26-community-nt, and was excited about possibility
    to use
    nested queries in the FROM clause of SELECT statement.

    It says in the doentation, section 13.2.8.8 (the paragraph one
    before the last) that nested
    SELECT clauses can return tables. I thought it means that table names
    can be returned as well.

    Say, one has many tables named as t_0001, t_0002, ..., t_9999. There is
    also a table called main,
    such that it has fields (id int, tname varchar(7)). I am wondering is
    there any way to do, for example

    DESCRIBE (SELECT tname FROM main WHERE id ==4)

    Thanks
    Alex

    sashap Guest

  2. #2

    Default Re: nested subquery in FROM clause


    sashap wrote: 


    I am not sure if that's actually possible. In fact I doubt it.
    Effectively, what you are doing is asking it to DESCRIBE a selected
    number of columns from the table (or a derived table which isn't
    actually really a table as such), which I don't think is possible.
    However. I see no reason why it wouldn't work if you created a
    temporary table using the data, and then parhaps used DESCRIBE,
    although I can't be sure...

    If you know what columns you are going to use in advance, you should be
    able to figure out the which column is holding which datatype first.

    Daz Guest

  3. #3

    Default Re: nested subquery in FROM clause


    sashap wrote: 

    Hi Alex, Just to confirm you can actually make a temprary table and use
    DESCRIBE on it. Although there appears to be a known problem with
    tables containing ASCII characters, which the MySQL dev team are
    currently working on patching.

    All the best.

    Daz

    Daz Guest

Similar Threads

  1. Avoiding subquery
    By André Hänsel in forum MySQL
    Replies: 3
    Last Post: February 17th, 06:48 AM
  2. Subquery
    By Ruszaj in forum Coldfusion Database Access
    Replies: 2
    Last Post: November 2nd, 04:50 PM
  3. using list in subquery
    By spacehog in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: March 9th, 11:23 PM
  4. SQL subquery question
    By derek in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 9th, 06:48 PM
  5. subquery with more than 1 fields
    By Calvin in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: June 30th, 05:53 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139