RBQL icon indicating copy to clipboard operation
RBQL copied to clipboard

Query Multiple Tables

Open GarThor opened this issue 7 months ago • 3 comments

I have multiple tables with similar data between them, and I'd like to know if it's at all possible to query all of them at once.

I see in the documentation, you don't need to provide a "FROM" table, when the current table is the one you want to query, but that seems like what I want to do?

Something like...

FROM table1.csv, table2.csv Select a.FirstName, a.LastName Where a.Age > 25

I don't think a join would be appropriate here, since I'm not trying to find adjoining information from a third table...

Sorry, I'm not exactly the most fluent with SQL, so maybe what I'm asking is already answered somewhere else...

I'm using RBQL from within vscode if it matters.

GarThor avatar Apr 30 '25 03:04 GarThor

The only hacky way to do this that I can think of is to use CLI rbql - the following trick should work:

cat table1.csv, table2.csv | rbql --query "select a.FirstName, a.LastName where a.FirstName != 'FirstName' or a.LastName != 'LastName'"  --delim , --policy quoted --with-headers 

Notice how this needs to filter out the header line from the second table, but this filtering condition is somewhat fragile. It should work more reliably if the files don't contain headers or only one of them does - then you can put it first in the cat argument list.

mechatroner avatar Apr 30 '25 04:04 mechatroner

Looks like I can eliminate that row with a little bit of powershell tomfoolery, before it even gets to rbql... but then, I may as well just query the data with powershell instead of in vscode...

ls *.csv | Select-Object -ExpandProperty FullName | Import-CSV | -- query code goes here--

or... alternatively, instead of (or in addition to) query code Export-CSV .\merged.csv -NoTypeInformation

GarThor avatar Apr 30 '25 20:04 GarThor

I have multiple tables with similar data between them, and I'd like to know if it's at all possible to query all of them at once.

I see in the documentation, you don't need to provide a "FROM" table, when the current table is the one you want to query, but that seems like what I want to do?

Something like...

FROM table1.csv, table2.csv Select a.FirstName, a.LastName Where a.Age > 25

I don't think a join would be appropriate here, since I'm not trying to find adjoining information from a third table...

Sorry, I'm not exactly the most fluent with SQL, so maybe what I'm asking is already answered somewhere else...

I'm using RBQL from within vscode if it matters.

Mwessc avatar May 08 '25 21:05 Mwessc