Stef Mientki wrote:
> hello,
> 
> I often want to see most of the columns of a table / view / query, but a 
> few I don't want to see.
> So I now create a huge list of fields,
> but isn't there a more typo-frindly way, like :
> 
> select * - field33 from table

A syntax option introduced in Date and Darwen's Tutorial D language, an analogy 
of which I've included in my Muldis D language, is the ALL BUT modifier.

Adapted into SQL with that same spelling, if you wanted all the fields except 
for "field33", it might be spelled like:

   SELECT ALL BUT field33 FROM table

Or, since SQL already tends to use ALL as an implicit alternative to DISTINCT 
to 
mean "include duplicates", we could use the * instead:

   SELECT * BUT field33 FROM table

Or if you don't like how that looks, maybe EXCEPT:

   SELECT * EXCEPT field33 FROM table

This could be generalized so you could have any field list on the left of the 
BUT/EXCEPT, so then you have the full flexibility of what you have now; eg:

   SELECT foo.*, bar.field20 EXCEPT foo.field5 FROM foo INNER JOIN bar USING 
(id)

Its nonstandard (unless the SQL standard has a feature like this which I'm not 
aware of), but I think very useful.

For example, often users want to get all the result fields except for the 
artificial fields just used to join the tables.

If SQLite's authors want to add such syntax as that, I support it, and other 
DBMSs could always follow suit.

-- Darren Duncan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to