|
Posted by Bob Smith on 07/28/06 19:19
On 7/28/2006 2:51 PM, Frankie wrote:
> I'm trying to run the following search query:
>
> $query =
> sprintf ("SELECT itemNumber, thumbnailURL, title, description, price
> FROM apparel,hats
> WHERE apparel.title OR apparel.description OR hats.title OR
> hats.description
> LIKE '%s'",
> $_POST['tfSearch']);
>
> but it returns this error:
>
> "Column: 'itemNumber' in field list is ambiguous"
>
> Both "apparel" and "hats" tables share the same columns specified in the
> SELECT clause.
>
> What I'm I missing?
Indeed it is ambiguous. To avoid this, use apparel.itemNumber or
hats.itemNumber in the SELECT list. Repeat for the other columns.
Also, to avoid an SQL injection attack, be sure to filter the input in
$_POST[...] using a function appropriate to your SQL implementation.
--
_________________________________________
Bob Smith -- bsmith@sudleydeplacespam.com
To reply to me directly, delete "despam".
Navigation:
[Reply to this message]
|