SELECT Electrodomestico
FROM Produtos p
INNER JOIN Sites s
ON locate(s.URL, s.URL) > 0
WHERE s.id = 1
This should return all records.
Edit: The way you want to do it, you can try:
SELECT Eletrodomestico
FROM Produtos
WHERE URL LIKE CONCAT((SELECT URL FROM sites WHERE id = 1), '%');
Your original instruction did not work because || does not concatenate two strings. This syntax is valid in DB2 but not in MySql. In MySql the | operator is the "Or".
Translating your instruction to Portuguese results in:
Returns all the records for which
- URL in the Products table is the same as the URL in the Sites table
- or '%' is true. But this second condition evaluates to FALSE.
To understand better, and as a joke you can replace your original query with:
SELECT Eletrodomestico FROM Produtos WHERE URL LIKE (SELECT URL FROM site WHERE id = 1) || 1;
I leave only one opinion. It would be a lot easier if you could save in the Products table the Site ID. Facilitated and much, the join of the tables. It also influences performance.