Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5530

wdlyons on "Displaying output from one table based on the info of another"

$
0
0

Hi,

I am having difficulties getting it to work. My interpretation is as follows

Am I correct in assuming that the code I use is

Where $tablename is the person table (a)and $tablename2 is the marriage info table (b and j)

`SELECT DISTINCT
$table_name.first_name AS spouse1_first_name,
$table_name.family_name AS spouse1_family_name, $table_name2.date_of_marriage,
$table_name.id,
$table_name.first_name AS spouse2_first_name,
$table_name.family_name AS spouse2_family_name
FROM $table_name
INNER JOIN $table_name ON $table_name.id=$table_name2.person_id OR $table_name.id=$table_name2.spouse_id
INNER JOIN $table_name2 ON $table_name.id=$table_name2.person_id OR $table_name.id=$table_name2.spouse_id `

Thanks in advance
Warwick


Viewing all articles
Browse latest Browse all 5530

Trending Articles