Forum Discussion
Use a parameter in a query in a MySQL database
- 9 years ago
Hi
because tx_id is a series of id numbers you need to pass them into SQL in a format it expects.
I used Text.Combine to create my parameter so it read '123','124','125' which is what i needed to pass to the SQL where clause. As you are using a number then i do not think you need the '' so you need to pass into SQL IN clause (123,123,123,123) etc if tx_id looks like 123,123,123,123 then you can concatenate it into your SQL like your example.
So the key to solving this is to make sure that tx_id results look exactly what SQL requires.
Regards
Mike
If I write "... where id in @tx_id" the error is "MySQL: Fatal error encountered during command execution."
Otherwise
the error is "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@'tx_id'' at line 13
I suppose it is a syntax error because when I replace the condition by "where id in (1,2)" I obtain results I am expecting.
I have also tried to modify the query directly in the Advanced Editor :
"let
dbQuery="select ... from ... where id in" & @tx_id,
Source = MySQL.Database("server", "name_database", [Query=dbQuery, CommandTimeout=#duration(0, 16, 40, 0), ReturnSingleDatabase=true])
in
Source"
but I have no result.
Nobody would have an idea ? :catsad: