这是我使用正常的WHERE条件
完成的QUERY<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.foodjoo.fjco.customViews.BYekanFontText
android:id="@+id/market_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:padding="@dimen/normal_plus_value"
android:text=" لبنیات > مارکت پیکی علی "
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead"
android:textColor="@color/light_black2" />
<android.support.v7.widget.RecyclerView
android:id="@+id/market_cat_recycler"
android:layout_width="match_parent"
android:layout_height="500dp" />
<com.foodjoo.fjco.customViews.BYekanFontText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:padding="@dimen/normal_plus_value"
android:text="ساعات کار"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead"
android:textColor="@color/light_black2" />
<android.support.v7.widget.RecyclerView
android:id="@+id/market_hours_recycler"
android:layout_width="match_parent"
android:layout_height="500dp" />
</LinearLayout>
这与JOIN完成相同的过程,但产生错误
SELECT FIXTURE.Fixture_ID, FIXTURE.Game_Date, TEAM.Team_Name,
OPPONENT.Opponent_Team_Name, FIXTURE.Results, FIXTURE.Score,
FIXTURE.Location
FROM FIXTURE,TEAM,OPPONENT
WHERE FIXTURE.Location='Home'
AND FIXTURE.TM_ID = TEAM.Team_ID
AND FIXTURE.OPP_ID = OPPONENT.Opponent_ID
GROUP BY Game_Date
ORDER BY Game_Date DESC;
我在这里做错了什么?请提出正确的解决方案。
谢谢。
答案 0 :(得分:1)
JOIN和WHERE的顺序不正确,JOIN必须在FROM之后和WHERE之前:
SELECT FIXTURE.Fixture_ID,
FIXTURE.Game_Date,
TEAM.Team_Name,
OPPONENT.Opponent_Team_Name,
FIXTURE.Results,
FIXTURE.Score,
FIXTURE.Location
FROM FIXTURE
JOIN TEAM ON FIXTURE.TM_ID = TEAM.Team_ID
JOIN OPPONENT ON FIXTURE.OPP_ID = OPPONENT.Opponent_ID
WHERE FIXTURE.Location='Home'
GROUP BY Game_Date
ORDER BY Game_Date DESC;