Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. Maybe not, but they didn't optimize it until the day AFTER they did.
  2. You can't use while() like that. You'll get to the end of the list first, and then row2 will always be null.
  3. That's not any better (post removed) -- not only did you ignore the rules by not using code tags, but once again, you dumped tons of code without indicating the one query that's the problem.
  4. Other than a missing index on first name, the correct way is to get a unique list of customers first, and then find the latest one for each.
  5. Don't use trig functions to calculate distance -- that's just wasteful. Latitude length is roughly proportional to degrees, while longitude is proportional to the cos (degrees); and a lookup table for every 5 degrees will suffice.
  6. You can't use group by and expect to get multiple rows!
  7. I'm sure I've answered this question dozens of times... see here for a good intro.
  8. If you need to the difference between 0 (zero) and unspecified (NULL), then you need NULL. If you need to the difference between '' (blank string) and unspecified (NULL), then you need NULL. Otherwise, don't bother.
  9. No one is going to look through 14kB of code -- what's the actual issue/
  10. Actually, you shouldn't have posted either -- and you forgot to use code tags. I don't see any tests of this code, nor any input/output scenarios.
  11. Data duplication should always be an optimization, not a starting point. Summary fields/tables are always a perfectly acceptable trade-off.
  12. Why not a simply SUM( IF(expr), 1, 0)?
  13. Yeah, don't cheat.
  14. Is that input or output? You show 4 column headers but only 2 columns of data.
  15. Don't mark your own topics as solved with posting the solutions.
  16. This is a classical question -- using "parent_id" makes it impossible to traverse the entire tree without a stored procedure or some psychic knowledge.
  17. Let's see some sample data.
  18. Don't double-post.
  19. ...which would be easy to see if you were looking at raw SQL.
  20. I just posted a solution like this a few days ago -- use a cross join for each condition you want to match.
  21. You should find the one that encompasses all possible user input.
  22. fenway

    Query Help

    With that GROUP BY, it's per company -- I'm confused.
  23. This is very much a php syntax question -- but use single quotes on the inside, doubles on the outside.
  24. Not a problem -- that's much more efficient, especially when there are very few that only have 2.
  25. Sounds like you need to parse out that field... and otherwise, yes, a JOIN will work quite well.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.