So I have pieced together the below and I'm not getting the expected outcome I am looking for
/* Build SQL string */
$(".ConvertSQL").click(function () {
$(".TableQuery").children("tbody").children("tr").each(function (i) {
$("#SQLstring").val("")
var $this = $(this);
var my_td = $this.children("td");
var first_col = my_td.eq(0);
var second_col = my_td.eq(1);
var query = "SELECT "
var text = $("#SQLstring").val()
query = query + "[" + first_col.html() + "].[" + second_col.html() + "],";
first_col = ""
second_col = ""
$("#SQLstring").val(text + query)
});
/* Remove some text from the start of the string thats not needed */
$('#SQLstring').contains('SELECT [undefined].[undefined],').remove();
});
There are no errors I'm receiving as such.
The code loops through the first 2 columns in my table and build an SQL query
The current outcome is:
SELECT [Test Table].[Test Field],
It should be basically concatenating eat row together to show something like:
SELECT [Test Table].[Test Field], [Test Table].[Test Field],