开发者

SQLIte Query, select everything that equals - Android

开发者 https://www.devze.com 2023-02-17 02:54 出处:网络
// get friends public Cursor getFriends(){ Cursor c = dataBase.query(SqConstants.FRIENDS_TABLE_LOCAL, null, null, null, null, null, null);
// get friends
public Cursor getFriends(){
    Cursor c = dataBase.query(SqConstants.FRIENDS_TABLE_LOCAL, null, null, null, null, null, null);
    return c;
}

I have multiple tables in a SQLite database in my application for android.

I want to select everything from a column in a Friends Table (which holds integers) and select everything that equals that integer from a User Table (in the primary column which also is integer) and the get all the users which equals the numbers stored in the friends column.

It was some while I managed SQL databases but I think the query for a MySQL database would be something like:

SELECT * UsersID FROM TABLE Users EQUALS LOCAL_FRIENDS_ID FROM TABLE Friends

I might be wrong that it would look like this, but something like it.

What I want is to do this in android code, from a cursor get all the Users from the Users table which ID is equal to the FriendsID.

How do I change the above method to make 开发者_JAVA百科it so?


You could just use the rawQuery

Cursor c = dataBase.rawQuery(SELECT * UsersID FROM TABLE Users EQUALS LOCAL_FRIENDS_ID FROM TABLE Friends, null)

If you need to use a actual parameter for the LOCAL_FRIENDS_ID

string[1] args = new String[LOCAL_FRIENDS_ID.ToString()];
Cursor c = dataBase.rawQuery(SELECT * UsersID FROM TABLE Users EQUALS ? FROM TABLE Friends, args)
0

精彩评论

暂无评论...
验证码 换一张
取 消