php - Two-part MySQL question: Accessing specific MySQL row, and column performance -


i have table 150 websites listed in columns "site_name", "visible_name" (basically formatted name), , "description." given page on site, want pull site_name , visible_name every site in table, , want pull 3 columns selected site, comes $_get array (a url parameter).

right i'm using 2 queries this, 1 says "get site_name , visible_name sites" , says "get 3 fields 1 specific site." i'm guess better way is:

select * site_list; 

thus reducing 1 query, , doing rest post-query, brings 2 questions:

  1. the "description" field each site 200-300 characters. bad performance standpoint pull 150 sites if i'm using 1 site?
  2. how reference specific row mysql result set site specificed in url? example, if url "mysite.com/results?site_name=foo" how do post-query equivalent of select * site_list site_name=foo; ?

i don't know how data "site_name=foo" without looping through entire result array , checking see if site_name matches url parameter. isn't there more efficient way it?

thanks,

chris

ps: noticed similar question on stackoverflow , read through answers didn't in situation, why i'm posting this.

thanks,

chris

i believe now, keeping sperated queries getting list of sites titles , 1 detailed view description single given site, good. don't pull unneeded data , both queries being simple fast.

it possible combine both queries one, using left join, maybe like:

select s1.site_name, s1.visible_name, s2.description site_list s1 left join   ( select site_name, description   site_list   site_name = 'this site should go description' ) s2 on s2.site_name = s1.site_name 

resulting in sites without matching name having null description, sort using

order description desc, site_name 

to site description first fetched row, eliminating need iterate through results find it, mysql have lot more work give result, negating possible gain hope for. stick have now, good.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -