DatabaseQuery

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Bernard.

Is it possible to work with two or more DataBaseQuery at the same time

In fact I would like to do something Like this :

strSQL="Select name from table"
If DatabaseQuery(strSQL)

While NextDatabaseRow()

strSQL2 = "Select * From Table2 where name = '" + GetDatabaseString(0)

If DatabaseQuery(strSQL)
While NextDatabaseRow(=

Code: Select all

      Wend
    EndIf
  
  Wend

EndIf


Thanks for your suggestions


BDu
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.

Hi Bernard,

Yes, is correcto but in you code only work with one database and 2 tables.

If you want work with more of one database, open the database with OpenDatabaseRequester(NumberOfDatabase 0,1,2 or more)and then change the database active with UseDatabase(0,1,2,....etc).

This is the system of work of ODBC.

Remember. All time you can change from one to other table only with the change in the query. And same facility for change the database with UseDatabase(0).

If you need know more over SQL, link:
http://sqlcourse.com/intro.html

Regards

Manolo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by effigy.

There is a better way to get the information you are looking for.

You can use the join command in SQL. Below is an example query.

select a.id, a.Name, b.id, b.address from namestable as a ;
left join locationtable as b on a.id=b.id

The way the join works the SQL statement will pull records from both tables (or just one) where a field in both tables are equal

Hope that helps.



Derek - PB Newbie
Post Reply