Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exclude a field from SQL
Message
From
08/04/2011 17:55:51
 
 
To
08/04/2011 17:40:12
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01506729
Message ID:
01506734
Views:
43
>Hi. Please note that I am in 7.0. Is there a way to exclude a field from a sql (without individually including all the other fields.)?
>I have modified an existing app and now Fox is asking for "_a", "_b", etc.

Sometimes that sort of thing arises from joining two tables and selecting all columns from both e.g.
SELECT ;
  * ;
  FROM Table1 ;
  INNER JOIN Table2 ;
    ON Table2.ID_Fld = Table1.ID_Fld

* In that case you will get result columns named with _A, _B suffixes.

* One way you can partially work around that is
SELECT ;
  Table1.* ;
  , Table2.ColumnIWant1 ;
  , Table2.ColumnIWant2 ;
  , ...
  FROM ... as above
With the above you still end up specifying individual columns for one of the tables. But, in many cases you need most or all of the columns from one table, and maybe only a few from the other so you can use the * on the most, and individually include from the few.

IMO it's not an inherently bad idea to individually name columns you want, rather than using *. It fits with the idea of only pulling across the columns you actually need - which can be important for slow connections or heavily loaded back-end servers. One downside to doing it is it's a little harder to code up-front, and may require more maintenance if table structures change.

If you find you're frequently using a query with a lot of individually named columns, you could consider creating a view for that. A view can help with maintenance as well.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform