Date: 11/03/05 (MySQL Communtiy) Keywords: php Thanks for all the suggestions in the previous post, but none of them seem to do what I want. After asking another friend, we eventually came up with this query (in PHP, thus the need for the backslashes before the square brackets) which does what I need:
$site = 'pp';
$slashedSearch = 'mini';
$query = "SELECT product_id, name, description, title, manufacturer,
warehouse_price, product_markup, supplier_markup, filename,
thumbnail_width, thumbnail_height, sell_price, minimum_price,
item_number, category_key
FROM product
INNER JOIN supplier
ON supplier_key = supplier_id
INNER JOIN picture
ON picture_key = picture_id
WHERE placement_{$site} = 1 AND
product.active > 0 AND
(name REGEXP '\[ ,.;:^\]$slashedSearch\[ ,.;:$\]' OR
description REGEXP '\[ ,.;:^\]$slashedSearch\[ ,.;:$\]' OR
title REGEXP '\[ ,.;:^\]$slashedSearch\[ ,.;:$\]' OR
manufacturer REGEXP '\[ ,.;:^\]$slashedSearch\[ ,.;:$\]' OR
product_id='$slashedSearch' OR
item_number='$slashedSearch')";
Source: http://www.livejournal.com/community/mysql/72426.html
|