2

I am doing queries over multiple databases in SQLite, and I'm having trouble using a .* in my queries. I have successfully used the ATTACH function to reference both databases:

dbOne.execute("ATTACH DATABASE 'dbOne.sql' as db1");
dbOne.execute("ATTACH DATABASE 'dbTwo.sql' as db2");

This query here gives me a syntax error (syntax error near *):

dbOne.execute("SELECT db2.myTable.* FROM db2.myTable");

Can I do db2.myTable.*? Or do I have to select each individual column one at a time?

SELECT db2.myTable.columnA, db2.myTable.columnB, db2.myTable.columnC, etc.

Thanks!

1 Answer 1

3

In case you have not solved this already, this will work:

a) dbOne.execute("SELECT * FROM db2.myTable");

b) dbOne.execute("SELECT abc.* FROM db2.myTable abc");

Also, you don't have to specify the database name when the tablename is unique across all attached databases.

b) is commonly used when you select or join multiple tables, e.g.

SELECT abc.*, xyz.* FROM db2.myTable abc, db1.myOtherTable xyz

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.