Topic on Talk:Quarry

Use of a selected db inside of a query

6
Achim55 (talkcontribs)

If a db is selected like USE enwiki_p; is there a way to check this selected db in IF or CASE statements? Pseudocode: if db == enwiki_p then etc. Background: Running similar queries against different dbs using the (nearly) same code, so that one has to change the USE statement only.

Edgars2007 (talkcontribs)

Not an answer to first question, but to (probably) your problem. You can use something like this:

use enwiki_p;
select * from some_en_wiki_table;

use dewiki_p;
select * from some_de_wiki_table;

use frwiki_p;
select * from some_fr_wiki_table;

It should work.

Achim55 (talkcontribs)

Not really. I found a way (see quarry:query/16164) but that's not sufficient, because other projects like wikisource or wikispecies have same names for their main pages.

Edit: Just had an idea, the page_id could be used additionally, that will work I think.

Zhuyifei1999 (talkcontribs)
Achim55 (talkcontribs)

Great, thank you very much!

Wargo (talkcontribs)