Welcome to WebmasterWorld Guest from 54.163.49.19

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)

New User

5+ Year Member

joined:Nov 20, 2009
posts: 4
votes: 0


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)

Moderator from US 

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

joined:Dec 10, 2005
posts:5551
votes: 24


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