sql - Retrieving data from multiple tables in phpmyadmin -


i have 3 tables, of them linked pk , fk. tables acc_details , acc_info , acc_bill

table : acc_info  id     |    acc_no         |  rate ______________________________________ 1      |         00001     |     0 2      |         00002     |     21 3      |         00003     |     21 4      |         00004     |     21   table : acc_details  id_dls |    acc_type       |  address         |  **id** ________________________________________________________ 1      |        store      |     pekan        |  1 2      |     water plant   |     kuantan      |  2 3      |       store       |     kuantan      |  2 4      |      pump house   |     kuantan      |  4   table : acc_bill  id_bill |        acc_no    |  charge_1        |  charge_2 ________________________________________________________ 1       |       00001      |     20.00        |  12.00 2       |       00002      |     15.00        |  16.00 3       |       00004      |    200.00        |  22.00 

pk ---> id , acc_no acc_info fk ---> id acc_details , acc_no acc_bill

i hoping outcome this

address     |    acc_no       |    rate   |  charge_1  | charge_2 _________________________________________________________________________________ pekan       |    00001        |     0     |   20.00    |   12.00 kuantan     |    00002        |    21     |   15.00    |   16.00 kuantan     |    00004        |    21     |  200.00    |   22.00 

now,i've tried this

select address , acc_no , rate , charge_1 , charge_2 acc_info , acc_details , acc_bill acc_info.id = acc_details , acc_info.acc_no = acc_bill.acc_no 

but error #1052 - column 'acc_no' in field list ambiguous can help?

select address ,        acc_info.acc_no ,         rate ,         charge_1 ,         charge_2 acc_info  join acc_details on acc_info.id = acc_details.id join acc_bill on acc_info.acc_no = acc_bill.acc_no 

it means acc_no exists in 2 joined tables, need specify acc_no want


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -