指定的表的列名無效 聯表查詢 列名無效

2021-10-17 02:20:29 字數 797 閱讀 7791

用到聯表查詢sql語句時 最後執行輸出總是報錯 說s.jprice列名無效   但這條語句在sqlserver中是可以執行的

到底是怎麼回事呀  求解  謝謝各位大神

jprice,mprice是spinfo表中的進價和賣價  xscout是xsjilu表中的銷售數量  iid是兩個表中的主外來鍵關聯

public void selectsppriceall() throws sqlexception {

float jprice;

float mprice;

int xscout;

float sum = 0;

connection con = database.getcon();

statement sta = con.createstatement();

string sql = "select sum((s.mprice-s.jprice)* x.xscout) from spinfo s,xsjilu x where s.iid=x.iid";

resultset res = sta.executequery(sql);

while (res.next()) {

jprice = res.getfloat("jprice");

mprice = res.getfloat("mprice");

xscout = res.getint("xscout");

sum += (mprice - jprice) * xscout;

system.out.println("所有商品的盈利總額為:" + sum + "元");

MySQL修改表的列名

修改表 1.修改之新增列 給stu表新增classname列 alter table stu add classname varchar 100 2.修改du之修zhi改列型別 修改stu表的daogender列型別為char 2 alter table stu modify gender char...

查詢表中所有列名及備註

select from fn listextendedproperty null,user dbo table cp jckqk column default select b.name as tblname,c.name as colname,a.value as description from...

Spring Boot JPA報錯列名無效的錯誤

今天碰到乙個奇怪的問題jpa中為了快速開發,結果找這個列名無效的問題都花了3個小時,還不如使用jpa的api直接寫!query query this.entitymanager.createnativequery su.tostring showck.class 這個條語句是將sql語句查詢出來的結...