3 messages in com.mysql.lists.mysqlRe: Problems creating SQL to search| From | Sent On | Attachments |
|---|---|---|
| Tyler Longren | 05 May 2003 13:23 | |
| Tyler Longren | 05 May 2003 13:29 | |
| Bruce Feist | 05 May 2003 14:23 |
| Subject: | Re: Problems creating SQL to search![]() |
|---|---|
| From: | Tyler Longren (tyl...@jdhost.com) |
| Date: | 05/05/2003 01:29:36 PM |
| List: | com.mysql.lists.mysql |
Thanks Dan,
I was toying with the thought of doing that a few days ago. I suppose I'll go back and do that. Thanks for letting me know that it works just fine!
Tyler Longren
----- Original Message ----- From: "Daniel R. Anderson" <da...@mathjunkies.com> To: "Tyler Longren" <tyl...@jdhost.com> Sent: Monday, May 05, 2003 3:22 PM Subject: Re: Problems creating SQL to search
I created a similar search function using PHP. If the user selected "Any" it would just use:
SELECT * FROM table; etc.
If they selected any options it would append:
WHERE
And each option.
Hope htat helps.
-Dan Anderson
On Mon, 2003-05-05 at 16:23, Tyler Longren wrote:
Hi everyone,
I'm working on a site that requires a search function. The user can serach the buyers guide via company name, state, or heading. Some companies don't have a heading. There are about 700 different headings. None of the search fields are required. Right now, it only works if something is entered in every search field. If nothing is entered, no search results are returned. Can I do this using only one sql query? Or will I have to evalutae the search fields first to see which ones are filled in?
Here's the sql: SELECT DISTINCT
company.name,company.city,company.state,company.companyid,company_heading.co
mpanyid FROM company,heading,company_heading WHERE company.state LIKE '%$state%' AND company.name LIKE '%$companyname%' AND company_heading.companyid=company.companyid AND company_heading.headingid='$heading' ORDER BY company.name ASC;
Thanks, Tyler Longren




