Two part question...(note that I'm using a PostGres)
My SQL query is formatted like this:
$.ajax({
url: "https://something?q=SELECT *database_final_form_merge where territory in ("+terrs+")",
type: 'GET',
dataType: 'JSON',
success: function(data) {
}
});
The variable terrs
is an array like this:
["D1VE3011", "D1VE3011", "D1VD2209", "D1VD2209", "D1VD2103", "D1VD2103"]
This formats the SQL query like this though:
SELECT* from database_final_form_merge where territory IN (D1VE3011,D1VE3011,D1VD2209,D1VD2209,D1VD2103,D1VD2103)
But it needs to be in this format (I think):
SELECT* from database_final_form_merge where territory IN ('D1VE3011','D1VE3011','D1VD2209','D1VD2209','D1VD2103','D1VD2103')
This works when I try it directly without an AJAX GET. Is there a different way I should be passing this array?
That's question 1.
Question 2...is there a way to pass that array so that only unique values are passed? You'll note that in my array there are duplicates, but wondering if there's a way to only pass along unique values.
Thanks.