www.webdeveloper.com
Results 1 to 4 of 4

Thread: (DESCRIBE [table]) as table in subquery?

  1. #1
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,714

    (DESCRIBE [table]) as table in subquery?

    Is this possible?

    PHP Code:
    SELECT
        
    `ds_param_tbl_columns`.`colfull`,
        `
    ds_param_tbl_columns`.`colshrt`
        
    FROM `ds_param_tbl_columns`, (DESCRIBE `ds_species`) AS `fields`
        
    WHERE `ds_param_tbl_columns`.`colname`=`fields`.`Field`
            AND `
    ds_param_tbl_columns`.`table`='ds_species'


    Or do I need PHP magic to get a similar result on my webpage?

  2. #2
    Join Date
    Dec 2013
    Posts
    63
    I don't think so. I've tried simpler query in mysql console client:
    Code:
    SELECT * FROM (DESCRIBE [table_name]) AS [alias]
    and it failed. Theoreticaly it should work but it failed, so I think that your query will also fail.
    I haven't thought about such queries before. After reading your post I thought that such queries are possible. When you type "DESCRIBE [table_name]" in console client you will see the result as text table, with columns and fields, as usually when you type "SELECT ..." query, so I thought it's possible.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,338
    You might have better luck with SHOW, as I believe it's part of the actual SQL syntax, whereas DESCRIBE seems to be more of a separate utility statement. I've not tried it, though, so caveat emptor.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Dec 2013
    Posts
    63
    I made some checks in MySQL console client.

    Both
    Code:
    DESCRIBE [table_name]
    and
    Code:
    SHOW COLUMNS FROM [table_name]
    give the same result.

    And both don't work as a subquery.

    Both
    Code:
    SELECT * FROM (DESCRIBE [table_name]) AS [alias]
    and
    Code:
    SELECT * FROM (SHOW COLUMNS FROM [table_name]) AS [alias]
    failed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles