I have a table of the following style
Father
|----|------- |-------|
| id | precio | tabla |
|----|------- |-------|
|1 | 50 | sxt |
|----|------- |-------|
|2 | 45 | ext |
|----|------- |-------|
then I have other tables
|----------------|
| detallessxt |
|----------------|
| movimientosxt |
|----------------|
| detallesext |
|----------------|
| movimientosext |
|----------------|
Currently from the webservice I make a query to father and store the table variable and then I do a SELECT on the corresponding details and movements, concatenating the name of the table.
"SELECT * FROM Detalles"+tabla+" WHERE ID=1"
"SELECT * FROM Movimientos"+tabla+" WHERE ID=1"
but I'm looking for a way to do this with a stored procedure
but I do not find how to nest the selects
to get for example
CALL obtenertodo(id);
and that I return
|-------------------|
| id |
|-------------------|
| precio |
|-------------------|
| detalles_attr1 |
|-------------------|
| movimientos_attr2 |
|-------------------|
I do not have access to the structure of the database, it is designed in a way and I only have permissions to use SELECT
, generate functions and stored procedures