You are here: Re: Linking tables to display data? « PHP Programming Language « IT news, forums, messages
Re: Linking tables to display data?

Posted by Rik on 10/19/06 22:41

Garry Jones wrote:
> I want to link two tables together to create a list. The unique value
> loppnum appears in both tables. I need to look up its corresponding
> value for each entry.
>
> table1 has 2 cols
> A Jag
> D Cht
> E Lio
> P Mkn
> Q Res
>
> table2 has 2 cols
> MN A
> PL D
> RT E
> PO P
> LM D
> NB D
>
> In the first table both values are unique
> In the second table the first value is Unique
>
> Now I need to display a list of data in this form
>
> MN Jag (Displays second table data and looks up value of A in first
> table) PL Cht (Displays second table data and looks up value of D in
> first table) RT Lio (Displays second table data and looks up value of
> E in first table) PO Mkn (Displays second table data and looks up
> value of P in first table) LM Cht (Displays second table data and
> looks up value of D in first table) NB Cht (Displays second table
> data and looks up value of D in first table)
>
> I have made a start
>
> $upgcollect='SELECT * FROM table1 ORDER BY scfmfor';
> $upg1=mysql_query($upgcollect);
>
> $ml_collect='SELECT * FROM table2 ORDER BY loppnmn';
> $upg2=mysql_query($ml_collect);
>
> That gives me two variables with complete table data.
> The rest of this is beyond me at the moment.
>
> Can someone please point me in the right direction.

SELECT
x.field1, y.field2
FROM table1 x
LEFT JOIN table2 y
ON x.field2 = y.field1

Grtz,
--
Rik Wasmus

 

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

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