0

Hi all,

I want to add an amend functionality to my system. Therefore i need retrieve data from 2 different tables and display it in a single form.

account_details ( account_number, full_name,____)

account ( account_number, name_with_initials,____)

When i try to retrieve data from these 2 tables,output comes as an empty form.Can anyone correct my query.

$sql =sprintf("SELECT account_details. full_name,phone_number,address,gender,date_of_birth,account.name_with_initials,account_type,fd_period"." FROM account_details,account"." WHERE account_details.`account_number`='%s'", mysql_real_escape_string($_POST['account_number']) );
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by heshanm
0

The complete 2 tables are as follows

account_details (account_number,nic,full_name,phone_number,address,gender,date_of_birth,
approved_status)

account (account_number,name_with_initials,account_type,fd_period,account_balance,
account_interest)

0

Is your both table have one to one mapping OR one to many mapping?
Also you should have primary key in both table.

If one to one mapping then check below query in phpmyadmin.

select * from account LEFT JOIN account_details ON account.account_number = account_details.account_number
0

Still not working...data not retrieved. It results an empty form.

account_number is the primary key.It is one to on mapping table. One customer can have only one account.

I am not selecting all the records from both tables. So is it ok to use "*" in the query?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.