Qidiruv so'rovini shakllantirish

0 ovoz
57 marta ko‘rilgan
so‘radi 29 iyul parmonov98 (827 bal)

Assalomu aleykum, hormanglar hurmatchi dasturchilar! 

Demak vazifa shunday qidiruv formasida kiritilgan string  oldik uni so'zlarga ajratib chiqdik, endi o'sha so'zlarni har birini bir nechta ustunlardan izlab ko'rish kerak.

men sinab ko'rgan usullar

1. usul xatolik berdi #1241 - Operand should contain 2 column(s)

SELECT 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 ('hello%' , '%salom%') IN (pt.post_title, pt.post_tags , pt.post_description) AND ct.id = pt.post_cat_id

2.usul bu ham xatolik berdi Cardinality violation: #1241 - Operand should contain 1 column(s)

SELECT 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%','%hi%') OR pt.post_description LIKE ('%hello%','%hi%') AND ct.id = pt.post_cat_id 

mysql so'rovlarda qanday xatolik bor yoki

qanday yechim topish mumkin bunga.?

har qanday berilgan yordam uchun rahmat

 

2 Javoblar

+2 ovoz
javob berdi 29 iyul Saidolim (3,160 bal)
tanlangan 13 avgust vejon
 
Eng yaxshi javob

Agar so`rovni yig`a oladigan bo`lsangiz. eng to`g`ri so`rovingiz:

SELECT 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 

bo`lsa kerak

izoh qoldirdi 29 iyul parmonov98 (827 bal)
javob uchun rahmat. meni fikrimcha ham yaxhsi so'rov bo'ldi
0 ovoz
javob berdi 29 iyul parmonov98 (827 bal)

2-usulni quyidagicha tartibda qilganda to'g'ri ishlarkan

SELECT
    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
    ('hello%' OR '%salom%') IN(
        pt.post_title OR pt.post_tags OR pt.post_description
    ) AND ct.id = pt.post_cat_id

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

...