I have a small block of code in bash like below
#!/bin/bash
query="select * from table where id = ${row_id}"
row_id=1
echo "$query"
row_id=3
echo "$query"
row_id=4
echo "$query"
expected output is below
select * from table where id = 1
select * from table where id = 3
select * from table where id = 5
But I am getting nothing as output
I know I am referencing variable before assigning it.
The idea here is to use reusable code instead of writing the same code at many places
How can I achieve what I want
select * from table where id =is not "nothing as output".