ginda Familiar Face
Joined: 11 Feb 2010 Posts: 28
|
Posted: Tue Mar 09, 2010 10:52 am Post subject: SQL query data from a loop being used in another loop? |
|
|
Hi everyone, really need your help very stuck on this issue.
I am querying a database which displays a name of user and then should display the users entire address as a expandable list record.
At the moment it displays the following:
>>(Name)Smith¬
>>(Address ID) 100
Instead of the address id i need to run another sql query which does the below:
select address1,address2,town,zipcode from table where addressID='100'
and should append the users address below the users name record?
How can i do this i.e. run another sql query with data from the current record and append to treeview?
Please please help!
My CODE
/*My sql statement*/
state0 ="select fname,addressID from table where fname='smith'"
/*Connects to DB*/
error = sqlite3_open("_gd", &conn);
/*Prepares sql query*/
error = sqlite3_prepare_v2(conn, state0, 2000, &res, &tail);
/*loops and retrieves each record from DB*/
while (sqlite3_step(res) == SQLITE_ROW) {
gtk_tree_store_append(store, &toplevel, NULL);
gtk_tree_store_set(store, &toplevel, LIST_ITEM, sqlite3_column_text(res, 0), -1);
gtk_tree_store_append(store, &child, &toplevel);
gtk_tree_store_set(store, &child, LIST_ITEM, sqlite3_column_text(res, 1), -1);
} |
|