{"id": "sql_queries:id3", "page": "sql_queries", "ref": "id3", "title": "Cross-database queries", "content": "SQLite has the ability to run queries that join across multiple databases. Up to ten databases can be attached to a single SQLite connection and queried together. \n Datasette can execute joins across multiple databases if it is started with the --crossdb option: \n datasette fixtures.db extra_database.db --crossdb \n If it is started in this way, the /_memory page can be used to execute queries that join across multiple databases. \n References to tables in attached databases should be preceded by the database name and a period. \n For example, this query will show a list of tables across both of the above databases: \n select\n 'fixtures' as database, *\nfrom\n [fixtures].sqlite_master\nunion\nselect\n 'extra_database' as database, *\nfrom\n [extra_database].sqlite_master \n Try that out here .", "breadcrumbs": "[\"Running SQL queries\"]", "references": "[{\"href\": \"https://latest.datasette.io/_memory?sql=select%0D%0A++%27fixtures%27+as+database%2C+*%0D%0Afrom%0D%0A++%5Bfixtures%5D.sqlite_master%0D%0Aunion%0D%0Aselect%0D%0A++%27extra_database%27+as+database%2C+*%0D%0Afrom%0D%0A++%5Bextra_database%5D.sqlite_master\", \"label\": \"Try that out here\"}]"}