Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. Sounds like you should be combining this into a single query -- your GROUP BY is working, but not across the for loop!
  2. There is no "good way" -- the docs say that you can request an index to made ASC or DESC, but AFAIK, this has not yet been implemented... there are a variety of hacks available.
  3. As far the PHP side is concerned it doesn't matter... it's 2 "queries", but one statement... something like this (untested) -- you may need to backtick the date column (reserved keyword!): SELECT c.storeNum, c.method c.date, c.subject as subject, c.details s.franchisee s.rfc FROM communications AS c INNER JOIN stores AS s ON c.storeNum = s.storeNum INNER JOIN ( SELECT storeNum, MAX(date) AS maxDate FROM communications GROUP BY storeNum ) AS rc ON rc.storeNum = c.storeNum and rc.maxDate = c.date ORDER BY c.date DESC
  4. You're right, a second query would be best... use MAX(datetimeField) on the comm table, and get back the date/time and storeNum... then join this derived table to the stores table.
  5. Nothing wrong with the order by... but with DESC, it can't use the index.
  6. Well, that's one out of three... not $trader, the string that you're passing to mysql_query().
  7. You need to put parens around the group of OR conditions.
  8. Well, earlier you had a parsing error, and now you have missing files.
  9. That's hard to belive.
  10. What's not working? Alert each value independently, make sure they're all numreic and what you expect.
  11. Really? This is terrible: SELECT * FROM isbn_similarities WHERE 1 ORDER BY 1; Why do you need 500K rows? Also, you have ORDER BY yourField DESC all over the place -- which means you're not using an indexes on these expensive filesort operations!
  12. First, echo the actual query, without PHP variables. Second, post the table structure. Third, getting back "*" from a GROUP BY makes no sense.
  13. Well, you're not using any index on the first table.. I can only assume you don't actually need 180K records? What's the query?
  14. That still doesn't answer my question... assuming a 30 second "grace period": SELECT * FROM `Example` WHERE `DateTime` BETWEEN '2007-08-28 15:24:44' - INTERVAL 30 SECOND AND '2007-08-28 15:24:44' + INTERVAL 30 SECOND
  15. According to the refman:
  16. Why not check this on the page for the currently loggedin usre?
  17. Not really a mysql problem at this opint...
  18. Define "closest".
  19. fenway

    Query

    So you want to select data from NOW until today at midnight. I get that part... but not the next part.
  20. Yes, ranks are complicated... there are a variety of ways to do this, all of which are uniquely complex.
  21. Or the query didn't execute sucessfully
  22. Looks like a double-post.
  23. If appropriate, this is better, since REPLACE does an implicit DELETE.
  24. Don't number the results on INPUT.
  25. This feels homework-y.... in any event, you should have a single table of questions, and another of answers, and yet another for the "two" different questionnaires/surveys/whatevers. Limits of 3 answers can be accomplished in code
×
×
  • 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.