Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. You're not supposed to store values from checkboxes that way -- not to mention that's not the correct ENUM syntax. Store answers generically.
  2. SELECT s.* , COUNT(h.status) FROM staff AS s LEFT JOIN hours AS h ON ( h.username=s.username AND h.status="sick" ) WHERE s.username="jbloggs"
  3. It's easier to keep archived "versions" in equivalent table structures -- or even in the same table -- and triggers aren't ideal for that.
  4. This is rapidly becoming php-only issue...
  5. That's what LEFT JOIN does, by definition.
  6. If I understand correctly, you know which IDs are associated with a given batch -- always. You simply want to produce a report showing all IDs, and whether they are complete or not. For complete, that's easy. For incomplete, that's not so easy. In your example, 100060 - 10020 you say are "obviously not used" -- why? Because there are no such IDs?
  7. Sorry, I don't follow.
  8. It's an identifier quote character.
  9. Yes, the * is lazy -- but in some cases (think: caching) it's preferable to retrieve the entire record.
  10. Assuming you have a reasonable number of branches, you can simply use the Pythagorean theorem to figure out the rough distance to each, and then take the shortest one. Don't bother with great-circle distance -- it's way too-resource intensive, and no one can drive that path anyway.
  11. Well, that depends on how much data you're returning -- in terms of phsyical size. If the resultset doesn't fit into memory, that's not ideal. But if you're returning GBs of data via a network datastream, you're limited by lots of other things.
  12. fenway

    mysql query

    Definitely do #3.
  13. The query takes 15 seconds to execute, or to return results?
  14. fenway

    Junction

    SELECT Colors.name, Flags.name FROM FlagsColors INNER JOIN Flags USING ( flag_id ) INNER JOIN Colors USING ( color_id ) Though I see no reference to "country" anywhere.
  15. And?
  16. Then you're storing that ID is a session, improperly -- just guessing.
  17. No need for credit -- but thanks anyway.
  18. What, the hotel california/
  19. How can it do something on send and then sometimes not? I'm confused by your description
  20. Muhhahaha +1
  21. Oh, 'cat' like 'category', not like the animal. That's why abbreviations are evil. So, back to your original question -- simply use a seen hash, and create a structure accordingly (push()-ing onto a keyed hash by each category for each animal), and then the output it is a breeze. That way, you can drop the ORDER BY, too -- and save the DB some work.
  22. Oh yeah -- definitely different tables -- there share almost nothing.
  23. Are you certain there are records that have matching results?
  24. I don't follow -- why do you need both/
  25. Well, before we move any further, I'm not sure why you have a table called "cat".
×
×
  • 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.