Frage

I want to build a simple project with the following tables:

 CREATE TABLE artist(
 artistid    INTEGER PRIMARY KEY, 
 artistname  TEXT
 );
 CREATE TABLE track(
 trackid     INTEGER,
 trackname   TEXT, 
 trackartist INTEGER,
 FOREIGN KEY(trackartist) REFERENCES artist(artistid)
 );

I want my app to be user-friendly so how may I display the artistname instead of the artistid in the spinner of My Track Form? What SQLite statement should I use? After displaying all the artist names, what SQLite statement should I use to insert properly in my database?

Track Form Example:

Track Name: [EditText]

Artist: [Spinners]

War es hilfreich?

Lösung

The following Statement returns a List of Artist names and their track-names.

SELECT a.artistname, t.trackname
FROM artistname a, track t
WHERE a.artistid = t.trackartist;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top