Page 1 of 1
More than one database query at a time
Posted: Sat Feb 11, 2006 3:08 pm
by jcoleuk
How can I do something like this:
Code: Select all
If DatabaseQuery("SELECT...") = 0
MessageRequester("Error", "DB ERROR: "+DatabaseError())
Else
While NextDatabaseRow()
DatabaseQuery("SELECT...") = 0
; Second database query!
Wend
EndIf
I need to be able to run a query using data retrieved for each row of the first query, can this be done in PureB? I can do it in PHP.
Posted: Sat Feb 11, 2006 4:10 pm
by Paul
Open 2 instances to your database
Code: Select all
OpenDatabase(0,"myDatabase"...
OpenDatabase(1,"myDatabase"...
UseDatabase(0)
If DatabaseQuery("SELECT...") = 0
MessageRequester("Error", "DB ERROR: "+DatabaseError())
Else
While NextDatabaseRow()
UseDatabase(1)
DatabaseQuery("SELECT...") = 0
; Second database query!
UseDatabase(0)
Wend
EndIf
Posted: Sat Feb 11, 2006 4:23 pm
by NoahPhense
Threads ..
Posted: Sat Feb 11, 2006 4:51 pm
by Fred
With PB4, each database commands has a database number as well.
Posted: Tue Feb 14, 2006 7:24 pm
by jcoleuk
Thanks Paul I used your method and it's worked great.
I'm a bit worried about the number of calls to the database I'm having to do, but I'll sort that out later.
Posted: Tue Feb 14, 2006 7:45 pm
by Paul
Are you not able to get the desired data by joining tables in your query?
Posted: Tue Feb 14, 2006 7:50 pm
by jcoleuk
I know that it can be done, I just don't know how to do it, yet. But I'll work it out before I release my program.