Dublikat rowlardan qanday qilib qutilish mumkin(qidiruv so'rovi)

0 ovoz
41 marta ko‘rilgan
so‘radi 29 avgust parmonov98 (809 bal)

https://yordam.uz/3553/qidiruv-sorovini-shakllantirish

yuqoridag tartibda so'rov amalga oshirilmoqda lekin  savollar bir record ni ko'p nusxada qaytaryapti.quyidagicha query
 

$subquery = "";

for($i = 0; $i < count($items['keywords']); $i++){

$subquery .= "pt.post_tags LIKE "."'%".$items['keywords'][$i]."% ' OR ";

if(isset($items['keywords'][$i+1]))

$subquery .= "pt.post_tags LIKE "."'%".$items['keywords'][$i].$items['keywords'][$i+1]."% ' OR ";

$subquery .= "pt.post_description LIKE "."'%".$items['keywords'][$i]."%' OR ";

if(isset($items['keywords'][$i+1]))

$subquery .= "pt.post_description LIKE "."'%".$items['keywords'][$i].$items['keywords'][$i+1]."%' OR ";

$subquery .= "pt.post_title LIKE "."'%".$items['keywords'][$i]."%' OR ";

if(isset($items['keywords'][$i+1]))

$subquery .= "pt.post_title LIKE "."'%".$items['keywords'][$i].$items['keywords'][$i+1]."%' OR ";

}

$subquery = rtrim($subquery, ' OR ');

#$subquery .= ")";

echo $sql = "SELECT ct.id, ct.cat_link, pt.id, lng_ct.cat_title,

   pt.post_title, pt.post_link, pt.post_description,

   pt.post_author, pt.post_img, pt.post_date, pt.post_cat_id 

FROM `cates_of_site` as ct, ".$lang."_posts_of_site as pt  , `".$lang."_cat_info` as lng_ct

WHERE (".$subquery.") AND ct.id = pt.post_cat_id

";

izoh qoldirdi 30 avgust Sardor Dushamov (1,513 bal)
Group lab yuboring
izoh qoldirdi 31 avgust parmonov98 (809 bal)
bunday narsani bilmas ekanman, nima narsa u?

1 ta javob

0 ovoz
javob berdi 02 sentabr Saidolim (3,126 bal)
tanlangan 05 sentabr parmonov98
 
Eng yaxshi javob

oddiygina distinct so`zini qo`shasiz bo`ldi. Group by dan tezroq ishlidi.

SELECT distinct ct.id, ct.cat_title, ct.cat_link, pt.id, 
       pt.post_title, pt.post_link,pt.post_content, 
       pt.post_author, pt.post_img, pt.post_date, pt.post_cat_id 
FROM `cates_of_site` as ct, en_posts_of_site as pt 
WHERE (
  pt.post_tags LIKE '%hello%' OR
  pt.post_tags LIKE '%hi%' OR
  pt.post_description LIKE '%hello%' OR
  pt.post_description LIKE '%hi%'
) AND ct.id = pt.post_cat_id 

izoh qoldirdi 05 sentabr parmonov98 (809 bal)
helped.thanks

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...