
SELECT
distinct(p.name),p.alt_name,a.first_last_name,t.name as trademark_name
FROM
store__products p
LEFT JOIN store__products_authors pa ON p.id = pa.product_id
LEFT JOIN store__product_authors a ON a.id = pa.author_id
LEFT JOIN store__trademarks t ON t.id = p.trademark_id
WHERE
p.name ILIKE '$q'
OR p.alt_name ILIKE '$q'
OR a.first_last_name ILIKE '$q'
OR t.name ILIKE '$q'
LIMIT 10";
Czy da sie jakos tak zbudowac zapytaniem bym wiedzial ze dopsowane zostało pole 'name' czy tez 'first_last_name' czy tez dowolne inne?