mysql - Reuse expression in SQL sentence -


i'm using mysql , i'm going mad trying simplify bit complex sql sentence.

the query this:

select `provider`.*,`products`.`placement`,`price`.`price`+    ifnull((select `price` `price` `handle`=      (select `group` `group_provider` `provider_id`=`provider`.`id`)),'0') `price` `provider`  left join `products` on `provider`.`id`=`products`.`web`  left join `price` on `price`.`handle`=`provider`.`id`  `products`.`type`='$product_type'   , `price`.`price`+    ifnull((select `price` `price` `handle`=      (select `group` `group_provider` `provider_id`=`provider`.`id`)),'0')>0 

this query working perfect, problem have repeated item , don't know how simplify it. repeated item i'm talking is:

  `price`.`price`+    ifnull((select `price` `price` `handle`=      (select `group` `group_provider` `provider_id`=`provider`.`id`)),'0') 

any idea simplify it? thanks

create view of data includes column , query view. once have created view query becomes simple:

select * your_view type = 42 , price > 0 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -