SQL SELECT * FROM tbl (HIDE 1 COLUMN)
Solution 1
Just specify the columns. You should be doing that all the time anyway as select * is a very poor programming choice. I don't know about mysql but in SQL Server I can drag all the columns over from the object browser and delete the ones I don't want, it takes seconds. Perhaps the interface you use has a similar functionality.
Solution 2
Try this out. Like he says, the SQL isn't pretty.
Select all columns except one in MySQL?
Solution 3
Well you (or I) could spend a bit of time writing some dynamic sql to query the columns in a table, generating a sql statement minus the column you want to ignore, then executing that dynamic sql.
Or you could take a deep breath and code it up for the 19 columns.
I know which I'd choose. I know which way is more maintainable and less error prone.
eistrati
Proud Father. Lucky Husband. Co-Founder @AdTechMediaPro. AWS Tech Partner @MitocGroup. Former @AWScloud and @HearstCorp.
Updated on June 19, 2020Comments
-
eistrati almost 4 years
I'm trying to do
SELECT * FROM tbl
, but out of 20 columns I don't want 1 particular column to be selected. Is there a dynamic way to do so? Just hate to specify 19 columns in the query!