Welcome to WebmasterWorld Guest from 54.158.143.40

Forum Moderators: open

Message Too Old, No Replies

New-B need help with SELECT. JOIN. WHERE

I don't know how to use WHERE with JOIN

   
1:37 pm on Dec 7, 2009 (gmt 0)

5+ Year Member



I have a little MySQL query that works well:

SELECT * FROM parts
JOIN bom ON parts_idparts = idparts
LIMIT 250

Does exacly what I want, well, so far. Now I like to filter the data from 'parts' with a FORM.

I like to squeeze in the string:

WHERE
type LIKE '%{$_POST['such']}%' OR
description LIKE '%{$_POST['such']}%' OR
value LIKE '%{$_POST['such']}%'

How I can use this?

4:34 pm on Dec 7, 2009 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



You just need to scope any ambiguous columns. FOr example:
SELECT *
FROM parts
JOIN bom ON parts_idparts = idparts
WHERE parts.type LIKE '%{$_POST['such']}%' OR
parts.description LIKE '%{$_POST['such']}%' OR
parts.value LIKE '%{$_POST['such']}%'
LIMIT 250