SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mySQL Query query - excuse the pun

    I was wondering if it is possible to SELECT (*) everything (BUT) with a MySQL QUERY? I have a large number of fields I want to SELECT FROM an table and I want them all but '1'. As its only 1 field I don't want it seems really annoying that I have to select every field I want individually and ommit the one I don't want.

    Is there anything i can do ?

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, not that i know of. is this through PHP or something, or the command line? if it's PHP, i wouldn't worry about it. it's actually faster to do SELECT * rather than naming all the columns if you're selecting (almost) all of them. now, if it's on the command line and you don't want to see the column, i can understand.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi & thanks for the advice.

    I think I have found a solution - the SELECT I need this for is for a 2 table join where both tables have column name id. I realised that SELECT * was much faster than SELECT field1, field2, field3 etc..... So I wanted to use * for both speed and simplicity - but then had the problem of having 2 'id' fields returned (I don't want and didn't need the id from the second table as I already had the value as table2_id held in table1 - this was used to join the 2 tables).

    So I did a bit of research and came up with the following (which works) : -

    PHP Code:
    SELECT Table2_Wanted_FieldTable1.* FROM Table1Table2 WHERE Table2_id=Table2.id'; 
    Although this keeps the Query nice and neat, do you think it will also be quicker than defining each individual column in the SELECT ??

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by ChilliBoy
    Although this keeps the Query nice and neat, do you think it will also be quicker than defining each individual column in the SELECT ??
    yes, it is when i tested it.

  5. #5
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the only field you don't want to select is a large text or a BLOB, then I don't think SELECT * is going to be faster because it takes time (and memory) to move data. I'd suggest being very careful with using SELECT *.


Bookmarks

Posting Permissions

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