List:General Discussion« Previous MessageNext Message »
From:Miguel Vaz Date:March 18 2006 2:28am
Subject:select from multiple tables
View as plain text  
	Hi guys,

	I am kinda new to mysql and on my endeavour to build a backend for a 
site i am building, i need to fetch data from a couple of tables, but 
dont know how to do it with a single select.
	Heres the problem:

	first table (products):

	id
	id_type
	name
	desc
	price

	second table (types):

	id_types
	name


	What i need is to list all the products and show the type name of 
each of them. On the products table, on the "id_type" field, i have 
only a number pointing to its type on the "types" column, what i want 
to know is how i can do a select to fetch all the product records and 
replace the number on "id_type" with its equivalente name from the 
"types" table.

	Sorry if i cant explain it correctly, but heres an example:

	table products:

	id	id_type	name	desc	price
	1	2	prod1	blah	45

	table types:

	id_type		name
	1		razor
	2		string

	I want the list to show:

	prod1	string	blah	45


	Thanks,

	Miguel

Thread
select from multiple tablesMiguel Vaz18 Mar
  • Re: select from multiple tablesPeter Brawley18 Mar