Newbie in need of serious help

Codes here !

Moderators: macek, egami, gesf

Woptastic
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Nov 17, 2002 3:22 pm

Newbie in need of serious help

Postby Woptastic » Sun Nov 17, 2002 3:28 pm

Here is the problem. I have a php page that will display various links such as chairs, couches, tables and such. Chairs has been given an id of 1 couches 2 and tables 3 and such. I have a database in which there are 2 tables, Product which contains id, SupProdID, SupID, ProdName, ProdDesc, ProdPrice. Supplier contains SupID, SupName, SupCity, SupState, SupZip, SupPhone, SupWeb. When a user clicks on chair (id 1)it should pull out all the records in the product table with all records id 1 as well as the supplier information. However I can not get this to happen. Can someone please give me as much guidance as they can.

Elena Mitovska
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Nov 12, 2002 12:11 pm
Location: Ukraine
Contact:

Postby Elena Mitovska » Sun Nov 17, 2002 11:02 pm

To retrive data from 2 table by one select query you eed to use LEFT OUTER JOIN or INNER JOIN constractuins of MySQL.
If every record in yuor Product table has its match in Supplier table use INNER JOIN, if it doesn't use LEFT OUTER JOIN. INNER JOIN fetches only those records that has its math in other table (matched by SupID)
For example, this quiery retrives information about both Product and Supplier from both tables:

Select distinct P.*, S.* from Products P LEFT OUTER JOIN Supplier S ON P.SupID=S.SupID WHERE P.SupID=......

Hope it helps :)

Woptastic
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Nov 17, 2002 3:22 pm

Postby Woptastic » Sun Nov 17, 2002 11:12 pm

What would that look like in php?


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 5 guests