Unanswered: SELECT statement that excludes a field or two?
While coding (PHP) especially with database transactions, I usually browse the content or check the the table structure directly from the 'terminal' or simply MySQL client. There are times that I want to view the records based on let's say 10 fields, but am interested only on 8 fields. So what command in SQL that explicitly exclude fields from a query or field list? In consequence, I will no longer type in 8 field names but instead a field name or two for exclusions. Thanks.
I agree entirely with the below (posted as a comment on said link):
Frankly, the only time someone should be selecting * is for some adhoc data discovery; in which case, the inclusion of some extraneous columns shouldn't matter.
Production level code should explicitly list the columns to be returned. The principal reason for this is to insure against schema changes. When a field is added to a table, select * will return it -- sometimes with unexpected results.
With the myriad of IDEs available for database developers, including the entire list of columns should not be a burden
However, i also noted another comment discussing views. If you really are continuously looking up data to check it, but want to omit your particular columns (large blob/text columns are a good example) then CREATE A VIEW with the specified columns you do want, then do SELECT * FROM <VIEW>
CREATE VIEW 'view_name' AS SELECT column1,column2,column3 FROM <table>;
SELECT * FROM view_name;