GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL query data from a loop being used in another loop?

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
ginda
Familiar Face


Joined: 11 Feb 2010
Posts: 28

PostPosted: Tue Mar 09, 2010 10:52 am    Post subject: SQL query data from a loop being used in another loop? Reply with quote

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);
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP