Advanced Search

Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Include column from neighboring table only on condition (MySQL)

  1. #11
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    @traq Hmm... I was hoping not to use multiple queries. If statements usually are a sign of messy/spaghetti code. Although I'm definitely sure you're better at SQL than I am, so I ask you: will using two separate queries be more efficient than using the last query? In other words, does the last query add a significant amount of wait to the execution time if all wild cards are on and we're just trying to get every single user?

    Thanks for your help.
    (I gaev u sum thx)

  2. #12
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Trying to do everything at once can be a "messy code" trap also. The "everything" query has a series of conditionals in it, in two different spots. All of that would be run every time you query. Choosing one statement or the other would cut out some logic in one case, and all logic in the other; so I doubt the combined query would ever be "as fast," much less "faster."

    But, like I said, I didn't test any of it.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  3. The Following User Says Thank You to traq For This Useful Post:

    Nile (08-12-2013)

  4. #13
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Alright, thanks for your help and everything! I haven't tested the code, but I'm sure it works (after looking over it). I'll set this thread to resolved.

  5. #14
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    You're welcome. I'm not as sure as you seem to be (mostly regarding the GROUP BY clause). But if it doesn't work, it's close. Let me know if there's any problems.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  6. #15
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    @traq Ah, I was just going to take your suggestion and do the two separate queries.

Similar Threads

  1. how to add another column on this table....
    By lilyoungfella in forum HTML
    Replies: 2
    Last Post: 05-25-2009, 12:45 PM
  2. php table INCLUDE
    By Anexxion in forum PHP
    Replies: 4
    Last Post: 04-14-2008, 10:27 PM
  3. how to do create,insert, select, delete temp table for this condition
    By giselle2008 in forum MySQL and other databases
    Replies: 0
    Last Post: 01-15-2008, 06:53 AM
  4. Help me to scroll the table column
    By dak in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 10-28-2006, 11:39 AM
  5. include external css based on condition
    By jigarshah in forum JavaScript
    Replies: 11
    Last Post: 10-10-2006, 09:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •