Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8755293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:49:39+00:00 2026-06-13T13:49:39+00:00

How could I select data from a table and include the data type with

  • 0

How could I select data from a table and include the data type with the values?
For example, I have table called EMPLOYEE with fname, lastname, phone, etc.
If I do:

SELECT * FROM EMPLOYEE

I get all the columns. If I do:

SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'EMPLOYEE'
ORDER BY ORDINAL_POSITION

I get all the column names and their data types.

I need to combine these two so I have the values displayed along with the data type.

I’m new to SQL but I have searched on the web some and tried various JOIN and UNION statements, but I could just be entering them wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:49:40+00:00Added an answer on June 13, 2026 at 1:49 pm

    You could SELECT EMPLOYEE.COL1, INFO.DATA_TYPE FROM EMPLOYEE, INFORMATION_SCHEMA.COLUMNS INFO WHERE INFO.TABLE_NAME='EMPLOYEE' AND COLUMN_NAME='COL1'
    But to select more fields, you’d have to add another instance of INFORMATION_SCHEMA.COLUMNS again with a different alias.

    But you should not do this for many reasons.

    Technically: CROSS JOIN (the tables in FROM listed simply with a comma) is much strain on the database server. FROM T1, T2 pairs up all rows of T1 with all rows of T2 and examines the result rows. If T1 has n rows and T2 has m then the result has n*m rows.

    Logically 1: You should not need this information to be returned. When you enter a query (a SELECT) the the returned schema is known; the query determines what datatypes the result columns are.
    Logically 2: Since every row has the same datatypes in the columns, you do not need the type information to be returned in every row. E.g. your example returning data of 1000 employees would unnecessarily transfer on every line that the AGE field is INTEGER, the NAME is VARCHAR and so on…

    If you somehow would not know the schema of the result (e.g. because of generated queries or the like) then the above solution would not help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this file 'gardens.php' , which pulls data from a table called 'generalinfo'
In T-SQL you could have a query like: SELECT * FROM Users WHERE User_Rights
Let's say I have a dynamically-created table that is filled with data from a
I have a products table, with the fields product, category and cost, of type
I have already created a report using list of data from my database. i
In MySQL, I have a simple "SELECT * FROM foo" query. I would like
Say that I have some SELECT statement: SELECT id, name FROM people ORDER BY
I have a site that displays data on travel products from a MySQL database.
I have a table which is full of arbitrarily formatted phone numbers, like this
I have drawn up the following PHP code which processes the data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.