simultaneous multiple database access
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
simultaneous multiple database access
MySQL allows you to copy a table from one database to another with this type of format:
CREATE TABLE database1.newtable LIKE database2.oldtable
INSERT database1.newtable SELECT * FROM database2.oldtable
The syntax database.table allows one to specify a table of a particular database, so you can use two different databases in a single command.
But LiveCode uses connection numbers to access databases, and only allows one connection number in a particular command (like the revExecuteSQL command).
So, how can one perform operations across databases, like copying a table from one database to another, which must be done in a single command?
Thanks,
Steve
CREATE TABLE database1.newtable LIKE database2.oldtable
INSERT database1.newtable SELECT * FROM database2.oldtable
The syntax database.table allows one to specify a table of a particular database, so you can use two different databases in a single command.
But LiveCode uses connection numbers to access databases, and only allows one connection number in a particular command (like the revExecuteSQL command).
So, how can one perform operations across databases, like copying a table from one database to another, which must be done in a single command?
Thanks,
Steve
Steve Alessi
Associate Professor
The University of Iowa
Associate Professor
The University of Iowa
-
- VIP Livecode Opensource Backer
- Posts: 369
- Joined: Sun Dec 19, 2010 1:10 am
- Location: UK
- Contact:
Re: simultaneous multiple database access
Hi, Steve. If you grant the user that you connect with privileges for both databases, then you can access both DB's from 1 query.
LiveCode Development & Training : http://splash21.com
Re: simultaneous multiple database access
Terrific! Can you give me a brief LiveCode example?
Thanks,
Steve Alessi
Thanks,
Steve Alessi
Steve Alessi
Associate Professor
The University of Iowa
Associate Professor
The University of Iowa
-
- VIP Livecode Opensource Backer
- Posts: 369
- Joined: Sun Dec 19, 2010 1:10 am
- Location: UK
- Contact:
Re: simultaneous multiple database access
You can run something like the following providing you have the appropriate privileges;
Check out the docs here...
http://dev.mysql.com/doc/refman/5.1/en/grant.html
Code: Select all
GRANT ALL ON otherDatabase.* TO 'user'@'localhost';
http://dev.mysql.com/doc/refman/5.1/en/grant.html
LiveCode Development & Training : http://splash21.com
Re: simultaneous multiple database access
Hi Splash21,
Sorry ... I was not clear in my question. I know how to grant permissions. What I don't know how to do is refer to two databases in one statement.
For example, in MySQL you can do this:
CREATE TABLE database1.newtable LIKE database2.oldtable -- which refers to two different databases
INSERT database1.newtable SELECT * FROM database2.oldtable -- which also refers to two different databases
But what would the equivalent syntax be in a LiveCode revExecuteSQL command? All the documentation and examples I can find demonstrate access to a single database, because only one connection number parameter is permitted.
Thanks again,
Steve Alessi
Sorry ... I was not clear in my question. I know how to grant permissions. What I don't know how to do is refer to two databases in one statement.
For example, in MySQL you can do this:
CREATE TABLE database1.newtable LIKE database2.oldtable -- which refers to two different databases
INSERT database1.newtable SELECT * FROM database2.oldtable -- which also refers to two different databases
But what would the equivalent syntax be in a LiveCode revExecuteSQL command? All the documentation and examples I can find demonstrate access to a single database, because only one connection number parameter is permitted.
Thanks again,
Steve Alessi
Steve Alessi
Associate Professor
The University of Iowa
Associate Professor
The University of Iowa
-
- VIP Livecode Opensource Backer
- Posts: 369
- Joined: Sun Dec 19, 2010 1:10 am
- Location: UK
- Contact:
Re: simultaneous multiple database access
If you are connected to a database and want some info from 'database2' included in the results, you can ....
...just specify the database name in the table alias
Code: Select all
SELECT users.name, colours.favouriteColour FROM users, database2.colours AS colours WHERE users.userId = colours.userId
LiveCode Development & Training : http://splash21.com
Thanks very much
Hi Splash21,
Thanks very much! That worked for me inside a revExecuteSQL command. I guess I should have tried it, because it is standard mySQL syntax. But because the revExecuteSQL command refers to a database connection number, I assumed you could only operate on one database at a time. Apparently, the database connection number in LiveCode is somewhat "fake". You only have to give SOME exiting connection number, and your commands can then refer to ANY databases you have permission to access in your server area.
Thanks again,
Steve Alessi
Thanks very much! That worked for me inside a revExecuteSQL command. I guess I should have tried it, because it is standard mySQL syntax. But because the revExecuteSQL command refers to a database connection number, I assumed you could only operate on one database at a time. Apparently, the database connection number in LiveCode is somewhat "fake". You only have to give SOME exiting connection number, and your commands can then refer to ANY databases you have permission to access in your server area.
Thanks again,
Steve Alessi
Steve Alessi
Associate Professor
The University of Iowa
Associate Professor
The University of Iowa