Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. Then you can self-join in that many tables.
  2. fenway

    [SOLVED] LIKE

    It's using the index... there are just a lot of matching rows.
  3. Are you sure the collation / charsets are identical?
  4. Sounds like you don't have the right password.
  5. Try this (untested); $sql = "SELECT pms.message_id , pms.from, pms.to, pms.subject, u1.username as from_name, u2.username as to_name FROM private_messages pms INNER JOIN users u1 ON ( u1.username = pms.from ) INNER JOIN users u2 ON ( u2.username = pms.to ) WHERE ( pms.from = $session->user_id OR pms.to = $session->user_id ) ";
  6. My guess is you're quoting NULL.
  7. There's no reason you can't use min/max in the same query--- but don't you need to group by userID *AND* eventID?
  8. Try using COUNT(st.prefered_subject) -- that is, on the non-matching table.
  9. Close... you'll need to use LEFT JOIN to pull in non-matching rows: SELECT s.subject as preferred_subject ,COUNT(s.subject) as total_subject FROM subjects AS s LEFT JOIN students AS st ON ( s.id = st.prefered_subject ) GROUP BY s.subject
  10. MySQL doesn't support this natively... look at lucene or sphinx.
  11. Well, you can, but not without escaping them... so you shouldn't.
  12. Simple store a reference to the user_id in each of the other tables.
  13. This is more of a php question -- you need to determine which fields were selected, map those to the table structure, and built your where clause accordingly.
  14. If you're stuck with this data, use FIND_IN_SET() -- as long as they're comma-separated, it will work.
  15. Well, "A or B" will cover "A and B"... try writing this for the single table, and then deal with the joins.
  16. Well, how many levels deep are we talking about, realistically?
  17. I'm not sure I understand... it sounds like you're searching two different tables...
  18. Well, you can keep on left join-ing, but this model of data organization is not meant to be recursive -- there's the list adjacency model, though.
  19. Unless you're going to have multiple per user, you don't need a separeate table.
  20. I honestly have no idea.... I ran this query: SELECT n.title,n.id,n.no_comments FROM zym4921_news AS n WHERE n.type="1" AND n.status="1" ORDER BY n.date DESC LIMIT 6 With only an index on date, and it's perfect... but as soon as you join in the other table, it blows up. Apparently, mysql 5.1 allows you to use an index hint specifically for order by -- but this seems like a bug to me.
  21. I don't know what you mean... echo that string.
  22. You don't want to store multiple values in a single field that ... use a separate table.
  23. Of course...
  24. What's not working about it?
  25. I would UNION each of the individual searches.
×
×
  • 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.