bazz
02-13-2008, 02:42 AM
Hi,
I am trying to select values from two tables and the column names from one of the tables. I have been able to do each select separately but I need your guidance and help to make one query do both jobs.
select column names
my $sth = $dbh->prepare ("SHOW COLUMNS FROM tbl_address FROM centralDb;
") or die "prepare statement failed: $DBO::errstr\n";
selecting the field values
my $sth = $dbh->prepare ("SELECT COLUMNS, BD.contact_id, BD.group_name, BD.premises_name, CNT.Contact_ID, CNT.Phone_Number, CNT.Fax_Number, CNT.Web_URL, CNT.email_Address
FROM tbl_businessDetails BD, tbl_contact CNT
WHERE BD.group_name = '$selected_group_name'
AND BD.premises_name = '$selected_premises_name'
AND BD.contact_id = CNT.Contact_ID
") or die "prepare statement failed: $DBO::errstr\n";
$sth->execute;
How can I make a single select, get me both lots of data?
bazz
I am trying to select values from two tables and the column names from one of the tables. I have been able to do each select separately but I need your guidance and help to make one query do both jobs.
select column names
my $sth = $dbh->prepare ("SHOW COLUMNS FROM tbl_address FROM centralDb;
") or die "prepare statement failed: $DBO::errstr\n";
selecting the field values
my $sth = $dbh->prepare ("SELECT COLUMNS, BD.contact_id, BD.group_name, BD.premises_name, CNT.Contact_ID, CNT.Phone_Number, CNT.Fax_Number, CNT.Web_URL, CNT.email_Address
FROM tbl_businessDetails BD, tbl_contact CNT
WHERE BD.group_name = '$selected_group_name'
AND BD.premises_name = '$selected_premises_name'
AND BD.contact_id = CNT.Contact_ID
") or die "prepare statement failed: $DBO::errstr\n";
$sth->execute;
How can I make a single select, get me both lots of data?
bazz