Mariadb – know if a JOIN query is possible

mariadb

I have one table like this:

urlalias

And one like this:

status

What I want to do is select that "1" from status in the second table if the product_id number matches the number in the query column in the first table and is prefixed by product_id=. category_id and others should be ignored. Is something like this even possible?

Best Answer

I used Magier's example to come up with this:

SELECT oc_url_alias.keyword, oc_product.status, oc_product.date_modified,
REPLACE(query, 'product_id=', '') AS keymatch
FROM oc_url_alias
JOIN oc_product on REPLACE(query, 'product_id=', '') = oc_product.product_id
WHERE oc_product.status = 1;

which outputs exactly what I need.

Thanks for all the help everyone posted.