Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2009
    Posts
    185

    Question Unanswered: Using a * in select statement.

    I have the following select to bind a form. Can I change it to use a * to bind all fields in the the three tables? Something like
    Select Flights.*,Battery.*,Planes.* .....

    SELECT Flights.iBatteryID, Flights.iPlaneID, Flights.iCycle, Flights.dDate, Flights.dTime, Flights.nFlightTime, Flights.nVoltage, Flights.iRechargeMah, Flights.nIR, Flights.sMode, Flights.sComment, Battery.sbDescription, Battery.ibTotalCycles, Battery.sDefMode, Planes.spDescription, Planes.dLDate, Planes.dLastTime, Planes.iFlights, Battery.dLastFlown, Battery.dLastTime, Battery.sCurrentMode, Flights.dTime, Flights.nTimetoCharge FROM Planes INNER JOIN (Battery INNER JOIN Flights ON Battery.abID=Flights.iBatteryID) ON Planes.apID=Flights.iPlaneID;

  2. #2
    Join Date
    Jul 2009
    Posts
    185
    I tried on a test form the following and it seems to work. Is there a down side to doing this vs listing just the fields that you want. This way I don't get caught in code trying to update a unbound field. And is a much simpler select statement

    SELECT Flights.*, Battery.*, Planes.* FROM Planes INNER JOIN (Battery INNER JOIN Flights ON Battery.abID=Flights.iBatteryID) ON Planes.apID=Flights.iPlaneID;

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yes - it is considered bad practice. It matters less with a personal\ desktop database like Access (though it still matters), but much more if\ when you progress to n tier applications.
    Reasons to not use SELECT * (and when to use it)
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Actually, to more specifically outline my position - you shouldn't blindly not do this because it is considered "bad practice". You should look at all the reasons that it considered so and decide. Personally I don't like it because what is returned by the query is out of the hands of the person that wrote it. If another 30 columns, irrelevant to the query, get added to one of the tables they will be returned in the query.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yes you can.

    Yes, using * is considered a bad practice, but I still use it extensively... especially for queries that support data entry forms.

    Never had a problem doing so either.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Sep 2008
    Location
    NM, USA
    Posts
    97

    Talking

    I guess it all depends on what you're using it for...I pretty much only use SELECT * if I have like... a combo box or a list box that return a very small number of records that I am sure is pretty static...

    ...of course it's always important to look down the road...and consider how the requirments of your database may change in the future when you're modeling your data. Data-independent data models are happy data models.

    So, in my opinion:

    DO use Select * when you have a rather small amount of static data, when you don't care about how slow your application might become because you're the only one using it, or if you're sadistic and you like seeing your end users squirm and laugh at them while their reports load at a snail's pace. (<-client)

    DON'T use Select * when you have a large amount of dynamic data; when you have mulitple people accessing it over the same network (especially in combination with the above); if you don't hate your clients.

    "Unix is user friendly... It's just very picky about its friends."

    The best things in life...are well-documented.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •