-2

I was reading SQL queries and got stuck with a doubt. Is there any SQL query to exclude a single column while using select statement?

For example, I have a table which contains data about student (s_name, address, email_id, ..... many more).

I want to select all the columns except email_id.

Tony
  • 9,672
  • 3
  • 47
  • 75
Ketan
  • 83
  • 1
  • 1
  • 12
  • just select expiicittally all the other column but not email_id – ScaisEdge Feb 28 '17 at 20:25
  • Just keep in mind that it's good habit to have a `static` result set. When you use the selected data lateron - how would you deal with a newly added column? Would that work for every possible datatype that it could possibly be? What if the new column - that is *not* `email_id` should be excluded as well. I had the exact same thoughts like you might have, but my final conclusion was that it totally makes sense to explicitly select the columns I want to include. – RuDevel Feb 28 '17 at 20:32
  • You should get a decent IDE for writing your select queries which will auto populate a `SELECT` statement with all the field names, then you can remove those you don't need. Have a look at Toad (which I think works with a number of different servers) or if you are using SQL Server try RedGate's SQL Prompt (expensive but worth it) – Tony Feb 28 '17 at 20:32

1 Answers1

0

I don't think there is a way to do it directly in a Select statement. But you can use this alternative:

How to select all the columns of a table except one column?

Community
  • 1
  • 1
EddyG
  • 2,051
  • 3
  • 22
  • 46
  • 3
    If it's a duplicate, flag it as such. Don't answer simply to include a link to another question. – mason Feb 28 '17 at 20:31