MySQL join query using like?

前端 未结 3 757
情深已故
情深已故 2020-11-29 07:27

I have been trying to get this working for quite a while now but it just doesn\'t seem to work, maybe it is is not even possible, what i am wanting to do is to perform a MyS

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 07:49

    SELECT p.products_id, pd.products_name, p.products_model
    FROM products_description pd
    JOIN products p ON p.products_id = pd.products_id
    WHERE pd.products_name LIKE CONCAT( '%', p.products_model, '%' )
    LIMIT 0 , 100
    

    First off you have to restrict your request by (p.products_id = pd.products_id) and LIMIT. And look what time it took. After that you can go and make comparison with (WHERE). If you gonna compare directly within JOIN you will put down your db if there are at list 20 thousands items. Beware.)

提交回复
热议问题