Hey guys
is there a way to select a field from a MySQL table into a variable?
I have a script that’s going to insert values :
var connection = new ActiveXObject(“ADODB.Connection”);
connection.Open(“connection stuff”);
var n = 0;
var a1 = [“Monday”,“Tuesday”,“Wednesday”,“Thursday”,“Friday”,“Saturday”,“Sunday”]
for (n = 0 ; n<7 ; n++){
var insertStatement = ‘insert into tablename (fieldname) values ("’+a1[n].toUpperCase()+‘");’;
connection.Execute(insertStatement);
}
connection.Close;
ignore the logic I’m just testing… Ideally, I would like to store the result of a select query into a variable while I’m in this loop and use it for other conditional logic, something like:
myVariable = ‘select field from table where pk = someValue;’
it would only ever return 1 field not a table
I don’t know how to write it … in my sql its :
set @myVariable := (select fieldname from tablename where pk = someValue);
can it be done?
Thanks, Richard