You are here: Searching Multiple Columns, Multiple Tables in MySQL... « PHP « IT news, forums, messages
Searching Multiple Columns, Multiple Tables in MySQL...

Posted by Nick Zukin on 10/04/06 11:10

Sorry if this is too DB oriented.

PHP 4.3, MySQL 3.23

I've got a somewhat complex search of a MySQL database I'm trying to make.
(At least it's complex to me.) And I'm wondering if it's better to try to
handle it in MySQL or to split it up into multiple processes using PHP.

Essentially, I have three tables: vendors, products, and a join table for
vendors and products:

VENDORS
-------
vendorid INT
vendorname VARCHAR
vendorcategory VARCHAR

PRODUCTS
--------
productid INT
productname VARCHAR
productcategory VARCHAR

JOINS
-----
xid INT
xproductid INT
xvendorid INT

I want to be able to do a keyword search of sorts with a list of vendors as
the result. However, I want one value from a form to be used to search
three columns in two different tables: vendorcategory, productname, and
productcategory. Of course, the join table would have to be used to make
sure that the product names and categories that match give corresponding
vendors.

There's probably some method of using MySQL to do this with one query, but
it's beyond me. And experience tells me that sometimes it's easier or
better to use PHP (or even necessary to use PHP) to get the results how I
want them, often splitting complex queries into two parts.

Any suggestions?

Thanks.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация