I am using mysql version 3.23.41 and perl version 5.6.1-26.72.3 with
perl-DBI version 1.18-1.  I'm having trouble putting together a statement
that will get specific fields from all the records in table1 and all the
fields from table2 where certain fields match the first table.  My problem
is that if there is no record in table2 with fields that match the specified
fields in table1, the record for table1 is not returned.  I hope this is not
confusing for you gurus but it is for me.  Here is a statement that I tried:

SELECT table1.field1, table1.field2, table2.* FROM table1, table2 WHERE
table1.field1 = table2.field1 ORDER BY table1.field1, table1.field2

I also tried this but it produced an SQL syntax error:

(SELECT table1.field1,table1.field2 FROM table1) UNION (SELECT * FROM
table2) ORDER BY table1.field1,table1.field2

I expected a return of records at least equal to the number of records in
table1.  The first two fields is the returned set should all have values but
I expected many of the remaining fields to be blank for many of the records.


Any help would be greatly appreciated and if I've been unclear, please let
me know and I will try to explain it better but this is really confusing me.

Thanks,
Chris

Reply via email to