Page 1 of 1

SQL,DB's, and LiveCode

Posted: Wed Nov 13, 2013 10:23 pm
by tjm167us
Hello everyone,
I know there is a "Database" forum, but I have come to know people in this forum and don't like making new friends ;). I just started using databases with LiveCode have some nagging questions I can't find in the docs.
When setting up an ODBC connection to a database, the liveCode lesson: http://lessons.runrev.com/s/lessons/m/4 ... using-odbc
has you follow a bunch of steps to create an ODBC connection and add a new "Data Source" for the test database. As part of these steps, they require that you point to the database that you want to open.

1. Does this mean that you can only use this ODBC connection for this one database? If I wanted to create another ODBC connection for another database, would I have to do this again?
2. How can you query two databases that belong in different directories? I found that the following simple join query works if the two databases are in the same directory:

Code: Select all

SELECT a.ID,b.ID "&\
        "FROM "&dB_aPath&".Table1 AS a "&\
        "LEFT JOIN "&dB_bPath&".Table1 AS b "&\
        "ON a.ID = b.ID
3. Any general pointers would also be appreciated regarding using LiveCode to interface to databases!

Thanks,
Tom

Re: SQL,DB's, and LiveCode

Posted: Thu Nov 14, 2013 1:17 am
by Mark
Hi Tom,

I understand from the lesson that you need to create connection for each database. I don't use MS Access, so I don't know, but I wonder if there is a way to add multiple databases to one connection.

What are the values in dbA_Path and dbB_Path? If you're using relative paths, try using absolute paths instead.

My book contains a section on databases, but not ODBC. It does tell you how to use LiveCode's database functions and commands.

Kind regards,

Mark

Re: SQL,DB's, and LiveCode

Posted: Thu Nov 14, 2013 7:42 am
by snm
You can Open and use as many databases as you need in the same time, but single SELECT statement can be addressed to only one of them. So you must także data from one db, then from second db, and then do the rest in your code.

Marek