Dynamic Table name on SQL Select Statement

I have a table that is planned to be accessed based on predefined variables. As an example :
I have 3 tables below:
Tbl_trans
Tbl_trans001
Tbl_trans002

In the “grid / form” application, by default the application uses tbl_trans, but when the user has [variable] 001, then the automatic table will be accessed by user001 is tbl_trans001. And so on for other users.

How to implement it?

notes :
I use sc 9.0.017 with mysql database

I don’t know if you need use 3 tables. Or use only 1 table with a new field for that. The new field can have the value for you filter.
So you will need only use a filter for your need.

I use different tables for each branch office. This is done for easy maintenance. So when there is a constraint in one branch does not interfere with transactions from other branches.

Use a variable for the table name in the SQL statement of the view and set the variable to one of three name depending on user code.
This works provided the three tables have the same colums name.

Can I used like that on my sql statement ?

SqlError.png

I have never done this. But you can try it if it works.

in SQL - SETTINGS -> VARIABLE FOR TABLE (Variable name used for replacing the table name. Please indicate the name of the table that will be replaced by the variable value)

I just learned the function of that setting
dynamic table names can finally come true

thx @alvagar

SqlStatement01.png