首页 > 解决方案 > What is the query to display data from 3 tables of mysql to JFrame?

问题描述

My sql query is unable to show data of database tables into JFrame

I connect my database in phpMYAdmin from JFrame .I joined these three tables of database in my query and apply set and get Text in my code.

This is my Query in mysql

SELECT * 
FROM agent AS a 
    INNER JOIN client AS c ON a.Agent_Id=c.Agent_Id 
    INNER JOIN policy AS p ON c.Policy_No=p.Policy_No 

This is my code in Java

while(rs.next())
        {
            int Agent_Id = rs.getInt("Agent_Id");
            Agent_Id1.setText(String.valueOf(Agent_Id));

            String F_Name = rs.getString("F_Name");
            Agent_Name1.setText(F_Name);

            float Salary=rs.getFloat("Salary");
            Salary1.setText(String.valueOf(Salary));

            float Commission = rs.getFloat("Salary");
            Commission1.setText(String.valueOf(Salary*1.1));

            int Client_Id= rs.getInt("Client_Id");
            Client_Id1.setText(String.valueOf(Client_Id));

            int Policy_Id = rs.getInt("Policy_Id");
            Policy_Id1.setText(String.valueOf(Policy_Id));

        }

Column 'Client_Id' not found.

Column 'Policy_Id' not found.

It only gives the data from agent table. I want to show from all these tables.

标签: javamysqldatabase

解决方案


推荐阅读