0

This is my 2 tables.

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

account (account_number, name_with_initials,account_type, fd_period,__)

I want to select records in both the tables. This is my SQL line.

$query ="SELECT account_details. nic,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=account.account_number";

The following error occurs.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.account_number=account.account_number' at line 1

5
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Anuradha Mandal
0

May be

$query ="SELECT account_details. nic,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=account.account_number";
0
$query ="SELECT ad.nic,ad.full_name,ad.phone_number,ad.address,ad.gender,ad.date_of_birth,a.name_with_initials,a.account_type,a.fd_period FROM account_details ad,account a WHERE ad.account_number=a.account_number";

In this code i have made alias of table account_details as "ad" and for account as "a".
And your error was that you have to write the name of fields along with table from which they are coming.

0

@ IIM; I tried your query in my coding. But it retrieves all the records irrespective of the account number. I want to display ONLY the relevant record set?

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.