-2

I am using Firebird and what I want to do is display 2 different select queries. Here is an example

select * from tblStates;
select * from tblTeachers;

This are two tables with 2 completely different columns. When I use the code above firebird will only display tblTeachers. What I want is to see both tblStates and tblTeachers as two different tables. I was told to use suspend but I don't know the syntax and when I just type suspend there is a unknown token error.

  • 2
    Please provide sample data and what you want the result to look like. Keep in mind that a query can only return a fixed set of columns for all rows. – Gordon Linoff Apr 22 '19 at 20:08
  • 1
    run it one query at a time. Similar to SQL developer (oracle), find a way to run all queries as a script (execute all). – jose_bacoy Apr 22 '19 at 20:19
  • `was told to use suspend` - that should mean they suggested you to write a PSQL `selectable stored procedure` - but it would hardly help you because "tables with 2 completely different columns" and the SP would have only one set of arguments. And if your queries from these tables would have same columns than you could just `UNION` them without programming SPs. All in all, if those are two unrelated tables - then you have to make equally two unrelated queries, each for one table. If those are related tables, you have to make one single `SELECT` which would be `JOIN`ing them on some condition – Arioch 'The Apr 23 '19 at 08:11
  • Firebird can only execute statements individually, so by itself, this can't work: you would need a tool that handles and displays these results individually. You will need to provide a lot more context to your question for us to even begin to answer this (eg what exactly are you trying to solve, in a query tool or are you writing an application that needs to display this, etc). – Mark Rotteveel Apr 23 '19 at 09:57

1 Answers1

0

I am unfamiliar with the details of Firebird. However, in doing some research, I came across this post that might help.

What you're looking for is considered a batch separator statement. In SQL Server, it would be something like:

SELECT * from myTable1
GO
SELECT * from myTable2
GO

This would return two tables in a table or database studio viewer. I did not see something similar for Firebird other than what is linked above.

However, the next question is why are you wanting this functionality? Are you sure there is not a relationship between States and Teachers, as per your example? If there is not, then a common practice would be to run your unrelated SQL statements and save the returned tables in memory for use in your application.

Sometimes, if you cannot figure out a way to do what you want, its a good idea to look back at exactly what your goal is and wonder if there might be a better way :)

Hope this helps.