I got two tables “links” and “categories” how do i get 4 colunms from links and one from categories?
**Links**
_id
link_title
link_desc
link_date
**Categories**
_id
cat_title
cat_desc
i need a single row like this
_id, link_title, link_desc, link_date, cat_title
and then use this in my cursor
private void fillData() {
Cursor linkCursor = mDbHelper.fetchAllLinks();
startManagingCursor(linksCursor);
String[] from = new String[]{ DbAdapter.LINK_TITLE, DbAdapter.LINK_DESC, DbAdapter.LINK_DATE, DbAdapter.LINK_ROWID, DbAdapter.CAT_DESC };
int[] to = new int[]{ R.id.title, R.id.content, R.id.date, R.id.headid, R.id.catdesc };
SimpleCursorAdapter links = new SimpleCursorAdapter(this, R.layout.linkrow, linkCursor, from, to);
//links.setViewBinder(new MyViewBinder());
setListAdapter(links);
}
I tried SQL UNION but it dont worked.
What you want is called a join. But to do this you need to either give two ids, or add a category_id column to the Links-table.
or after adding the column
More information: