I am trying to make a query for SQL Compact
It is basically these queries, but I was hoping I could combine them into one.
1.
SELECT schoolId,opponent
FROM TEAM_SCHEDULE
WHERE seasonId = " & i & "
AND gameid = " & currentGame & "
ORDER BY id"
These are variables, trying to eliminate them at some point
currentMatch(0) = schoolId
currentMatch(1) = opponent
2.
SELECT id
FROM player
WHERE school = " & currentMatch(0) & "
AND starter = 'TRUE'
AND game_id = " & currentGame & "
ORDER BY weight
3.
SELECT id
FROM player
WHERE school = " & currentMatch(1) & "
AND starter = 'TRUE'
AND game_id = " & currentGame & "
ORDER BY weight
I was thinking I could do something like this, but I ran into a problem trying to figure out how to add the two schools to the query.
cmd.CommandText = "SELECT b.id, player.id" &
" FROM player b" &
" WHERE player.school = " & currentMatch(0) &
" OR player.school = " & currentMatch(1) &
" INNER JOIN player" &
" ON b.weight = player.weight" &
" ORDER BY player.weight"
To hopefully clear up any confusion, I am trying to:
- Select 2 schools(int) from team_schedule, schoolId and opponent.
- Select all starters(‘True’) at every weight from both of those schools.
- Pair up the starters from each school according to weight.
- Be able to select each pair and manipulate the data.
Appreciate any help!
This is the parsing error from your query Nikola,

This might be your query. You can state the same table more than once, but you need to provide different alias to each one. In this case player is listed twice as p1 and p2. Match on players weights is also done in join part, but it might be in where clause.