문제

Is it possible to combine * syntax with table abbreviations?

I want to do something like:

"SELECT subfunds.* FROM subfunds S" +
" INNER JOIN funds F ON S.id_fund = F.id" +
" WHERE F.fund_short IN('" + stSQLFundList + "')"

The above code gets a syntax error

"invalid reference to FROM-clause entry for table "subfunds".

I already found that if I do

"SELECT * FROM subfunds S" +
" INNER JOIN funds F ON S.id_fund = F.id" +
" WHERE F.fund_short IN('" + stSQLFundList + "')"

then I get all fields from both tables rather than from the subfunds table only.

So how do I get all fields from the first table (and none of the other tables' fields) in my answer set while also being able to use the single-letter table abbreviations?

도움이 되었습니까?

해결책

Change your code to this and you will get all fields from subfunds.

"SELECT S.* FROM subfunds S" +
" INNER JOIN funds F ON S.id_fund = F.id" +
" WHERE F.fund_short IN('" + stSQLFundList + "')"

If you are using an alias, then you want to reference that table by it's alias.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top