Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. fenway

    if question

    Try explaining that again.
  2. You can only use USING if both fields are named identically in both tables... ON allows you to specify the column names explicitly (e.g. when one is called "id" in the staff table and "staffID" in the dept table).
  3. Actually, neither table would be related directly -- you'd have a third table linking students to classes.
  4. Yikes... I guess that works... mysql has spatial functions if you're actually using this for something meaningful.
  5. I'm confused -- you want just a single row? the most recent one for each user? Please clarify.
  6. If you use ENUM, you can refer to the actual values, not just their bit value.
  7. How are you "deleting" this table? What do you get from phpmyadmin?
  8. Usually this is a mess because magic quotes are often on, too.
  9. No problem... glad you got it working. Basically, all the left join-ed fields are NULLed out on non-matches, so adding a condition to the where clause will always evaluate to false -- the join condition is evaluated *before* the NULLing out (necessarily, because otherwise it couldn't find them!).
  10. It shouldn't work -- you have 2 separate indexes, so it requires searches on each one independently. You're telling me you don't have an index that spans both columns? Maybe it combines them now? Which version?
  11. Oops, missed that... good catch; in general, I always count on the "joined" field. Glad you got it working.
  12. I'm confused... if you have it spanning two columns, you always need to refer to those.
  13. Much easier just to flag them.
  14. You need: SELECT question.id, question.name FROM question LEFT JOIN `quest-form` ON (question.id=`quest-form`.quest_id AND `quest-form`.form_id=1 )WHERE `quest-form`.quest_id IS NULL
  15. What do you mean? Increment a @rownum variable in your query, like this: if(@a, @a:=@a+1, @a:=1)-1 as rownum
  16. Searching "URLs" doesn't sound particularly user friendly...
  17. How about this? SELECT ad.ad_id, ad.owner_api, ad_log.sess_id, COUNT(*) AS num_times_played FROM ad LEFT JOIN ad_log ON ( ad_log.ad_played = ad.ad_id AND ad_log.sess_id = 5 ) WHERE ad.owner_api = 1 GROUP BY ad.ad_id
  18. Until you echo that query in plaintext, we can't possibly know.
  19. With user variables...
  20. I have no idea what that's all about -- and it won't have anything to do with your other string.
  21. I'm not sure what you mean.
  22. You want a left join to include non-matching rows, and then filter only those that don't match (i.e. null-ed out): select s.* from staff as s left join depts as d using ( staffID ) where d.staffID IS NULL
  23. For sure! SELECT sharedCol1, null as col2, sharedCol3, 'outbox' as source from table1 UNION ALL SELECT sharedCol1, col2, sharedCol3, 'inbox' as source from table2
  24. Even so, you should set "ONLY_FULL_GROUP_BY" in the sql_mode because otherwise you'll end up with a lot of garbage.
  25. Of course... SELECT null as col1, realField as col2, null as col3, etc....
×
×
  • 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.