Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. That depends on the relationship between the tables... but yes, if 1-to-1, then limit 1, not limit 5.
  2. fenway

    ifnull

    get what value? if what is null?
  3. Echo $sql... what does it do now?
  4. Do you really need to store this?
  5. Did you take a look here?
  6. I'm confused... you said you only wanted those with all three matching... how is this dynamic?
  7. One is primary, and the other is the FK... that's exactly what you want. In fact, you can replace left join `Pictures` on ( Pictures.EventID = Events.EventID ) with left join `Pictures` using ( EventID) for that very reason.
  8. How are these tables related? Sounds like you need to read up the adjacency model.
  9. Sigh.... don't believe me, believe the manual:
  10. Please explain...
  11. Interesting... I've never actually used GROUP BY in this type of scenario... maybe it doesn't really work? Hmm.
  12. from `Events`, `Admins`, `Pictures` Where Events.Start_Date >= '2008-01-19 15:05:23' and Events.Active = '1' and Pictures.EventID = Events.EventID and Admins.AdminID = Events.CreatorID Group By Events.EventID Order By Start_Date DESC becomes: from `Events` left join `Admins` on ( Admins.AdminID = Events.CreatorID ) left join `Pictures` on ( Pictures.EventID = Events.EventID ) Where Events.Start_Date >= '2008-01-19 15:05:23' and Events.Active = '1' Group By Events.EventID Order By Start_Date DESC
  13. Or "1 DAY", depending on what you actually mean.
  14. switch "select *" to "delete t1"
  15. WHERE date_purchased >= NOW() - INTERVAL 24 HOUR
  16. Yup, that's the one.
  17. It should read: $insertgrades = $db->sql_query("INSERT INTO ".$prefix."_tl_course_grades (Course_ID, SOMS_KEY, UID, Academic_Year, Final_Grade)". " SELECT Course_ID, SOMS_KEY, UID, Academic_Year, AVG(TL_Avg) AS FinalGrade
  18. Also, there's an unnecessary level of indentation.
  19. If the row isn't already there, it's an insert --- you can specify 4/8 columns if you want. If it is there, it's an update. Whree's the confusion/
  20. Let's forget about the insert for a minute... let's work on selecting the rows. You have g.UID -- so distinct will likely do nothing.
  21. Is that because I took one of the tables out of the DELETE clause? I did that because I didn't want it to actually delete the category, just the threads and replies that were in that category. Is there anyway to get it to work without that third table listed? The query you use to find the rows in each of the tables has nothing to do with which ones are deleted -- so you can still join however you choose, and only select the ones you want.
  22. First, echo $query. Second, add a mysql_error() call to make sure there are no syntax errors.
  23. See the sticky in the child forum.
  24. Easier way in simply to use an IN() clause with the product_ids, and then checking the count() = 3 with a having clause.
  25. Don't you mean: SELECT distinct user_id,SUM(rating_total_points) AS total FROM video GROUP BY distinct user_id ORDER BY total DESC
×
×
  • 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.