0

Im new in DB world but I'm so excited about it.

So I have extract some data from a DB where I have a table called movements and others called movements_YYYYMM where the detailed information is so YYYY is the year and MM the month, So I have,

So I have tables like movements_202001 or movements_200701, th thing is that I need to extract some information from movements, and depending of column lapse on it I need to extract some information from "movements_+.movements.lapse" but I don't know how to properly concatenate this info in postgres.

And I don't even know if this type of querys are possible.

I was thinking in somethig like:

SELECT mv.prfix||' '||mv.number AS invoice, mvm.count
FROM movements mv, movements_+mvm.lapse mvm...

I know that's not the right way to concatenate

Thanks in advance for your help.

  • Hi, interestng, not sure if this might help https://stackoverflow.com/questions/24775635/left-join-with-dynamic-table-name-derived-from-column - could also create a view from multiple tables so you just join against the view – IronMan Oct 09 '20 at 20:52
  • If you want to query all of this information at once, and all of these tables have the same structure, perhaps consider storing them all in the same table? – Blue Star Oct 10 '20 at 01:35
  • It is not possible, they have a similar structure but not equal, some columns are equal, and for this matter I just use that columns. – yeferson cordoba Nov 04 '20 at 22:10

0 Answers0