No results when running a database query using LIKE

Developer
Şundan United Kingdom
May 2023 tarihinden beri üye
SELECT * FROM lc_products where  lc_products.quantity > 0

this works fine

SELECT * FROM lc_products WHERE lc_products.keywords  LIKE '%test%'  AND lc_products.quantity > 0

this does not the function returns an empty array, using the basic:

database::query($query);

all help appreciated

Moderator
Şundan Lithuania
Mar 2016 tarihinden beri üye

There is a typo in lc_product.keywords. Should be lc_products.keywords

And if you are not using JOIN then your query could be like this instead:


WHERE keywords LIKE '%test%'
AND quantity > 0```

Do you want to be more specific what are you trying to do with this query in the product page?

As this is a separate problem from the first one.
Developer
Şundan United Kingdom
May 2023 tarihinden beri üye

Received by Show Products
Object { matchedProducts: [], numberOfResults: 0 }
search:810:13
No products found or products is not an array

still shows an empty array using LIKE

tried with:


SELECT * FROM lc_products WHERE keywords  LIKE '%acer%'  AND lc_products.quantity > 0

literally no response when using LIKE,

if i run other queries without LIKE it works fine.

tim
Founder
Şundan Sweden
May 2013 tarihinden beri üye
tim

I don't see any errors in your query.
What happens if you run the same query in phpMyAdmin?
What happens if you skip the quantity condition?

You might want to use find_in_set() instead of like for matching a value in a set.

Developer
Şundan United Kingdom
May 2023 tarihinden beri üye

It works absolutely fine in phpmyadmin and mysql and returns the correct 28 matches, however if i run it from the script the query produces an empty array

What happens if you skip the quantity condition? same result

if you want to anydesk to view what i am doing let me know i can screenshare and show you exactly whats going on

Developer
Şundan United Kingdom
May 2023 tarihinden beri üye

Issue resolved, it was related to max execution time being set to 600, in mysql 8.2 the time is in milliseconds not seconds.

Siz
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.