Rhino wrote:

> Your design seems fine, although you haven't explained how the field
> and field_lookup tables join to the others so I am making some
> assumptions.

Table field_lookup has two values defined as primary keys: ID_company and
ID_field
Thus, using simple query like:

SELECT company.name, field
FROM company, field, field_lookup
WHERE company.ID = field_lookup.ID_company && field.ID =
field_lookup.ID_field

i can get which company does what. In the matter of fact, i found some
solution to my problem by using following query:

SELECT company.name, city, state, street, number, company_telephone.naziv AS
tel_naziv, field
FROM company, field, field_lookup
LEFT JOIN company_address ON company.ID = company_address.ID_company
LEFT JOIN company_telephone ON company_address.ID =
company_telephone.ID_company_address
WHERE company.ID = field_lookup.ID_company && field.ID =
field_lookup.ID_field
ORDER BY rank

But now, if one company doesn't have its field of work entered it won't be
displayed.

> I think your problem is that some of your Left Joins should be Inner
> Joins. Are you familiar with the difference? Remember, a left join
> will pick up "orphan rows" - rows that don't have an equal, non-null
> key in the other table - and add them to the result. I think that's
> what is happening here.

But if i use INNER JOIN i will see only subjects who have all the data
entered. You can for instance have subject who has only address and doesn't
have phone number and it won't be listed. I am not so familiar with
different types of JOIN so any help is appreciated.

Thanks for the help!

--
Regards,
Marko


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to