SQL question

Sharky Forums


Results 1 to 5 of 5

Thread: SQL question

  1. #1
    Catfish
    Join Date
    Sep 2000
    Location
    bc
    Posts
    185

    SQL question

    is there any SQL command that can return a column name?
    like if tables have 4 columns: ID, name, price, qty
    i need a function/sql statement that can return those strings (column name) but i never seen this before...
    so does it exist in sql?
    thanks
    Help!!! I'm swimming with the sharks...!!

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Question

    This depends on what DBMS you're using. For example, I know under Oracle, you can simply say "desc <tablename>" and it will spit out the table structure for you.

    I've always been curious if MySQL had some equivilent to that...but I haven't found it.

    What exactly are you trying to accomplish?

  3. #3
    Reef Shark mefisto3's Avatar
    Join Date
    Jul 2001
    Location
    Melbourne, Vic, Australia
    Posts
    429
    MySQL has:

    describe <tablename>

    which also outputs the table info.

  4. #4
    Hammerhead Shark krack_it_up's Avatar
    Join Date
    Feb 2001
    Location
    Phoenix, AZ USA... the one just south of Canada
    Posts
    1,831
    MS SQL has quite a few options as well, you can try this

    SELECT a.name
    FROM syscolumns a
    JOIN sysobjects b
    ON a.id = b.id
    WHERE b.name = '<tablename>'
    AND b.type = 'U'

    This will give you a list of all the columns in a table.
    Last edited by krack_it_up; 02-20-2002 at 08:30 PM.
    MMMMMMMMMM...... BAR-B-Q
    -- Homer Simpson

  5. #5
    Catfish
    Join Date
    Sep 2000
    Location
    bc
    Posts
    185
    i'm using Access database and VB for the program
    Help!!! I'm swimming with the sharks...!!

Posting Permissions

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