Getting the input List of a WHERE IN Filter for SQL QUERY From A File or a Local Table












0















I have a simple SQL Query. However, the query has a where filter which takes a list.



The list contains at least 2000 items and it is becoming extremely inconvenient to put the long list into the query itself.



I was trying to find if I can create a table/ file and call that into the query instead.



EXAMPLE CODE:



Select * from Table_XXXX where  aa = 'yy'  and date > zzz  and mylist = [..............]


So instead of the list above, I will like to call the file (locally) in which the elements of the list reside or a table (locally and not in the database) in which the elements are in a column...



Any help will be appreciated.










share|improve this question

























  • At that point it's probably best to put all the items into a temporary table and use it as a subquery with IN or EXISTS, or as part of a join.

    – Shawn
    Nov 20 '18 at 5:09













  • Neither of your preferred options are possible in mysql , I don't know about pandas.

    – P.Salmon
    Nov 20 '18 at 7:39











  • As far as creating a table how can I call a local table and not a table in the database?

    – Stan
    Nov 20 '18 at 17:46
















0















I have a simple SQL Query. However, the query has a where filter which takes a list.



The list contains at least 2000 items and it is becoming extremely inconvenient to put the long list into the query itself.



I was trying to find if I can create a table/ file and call that into the query instead.



EXAMPLE CODE:



Select * from Table_XXXX where  aa = 'yy'  and date > zzz  and mylist = [..............]


So instead of the list above, I will like to call the file (locally) in which the elements of the list reside or a table (locally and not in the database) in which the elements are in a column...



Any help will be appreciated.










share|improve this question

























  • At that point it's probably best to put all the items into a temporary table and use it as a subquery with IN or EXISTS, or as part of a join.

    – Shawn
    Nov 20 '18 at 5:09













  • Neither of your preferred options are possible in mysql , I don't know about pandas.

    – P.Salmon
    Nov 20 '18 at 7:39











  • As far as creating a table how can I call a local table and not a table in the database?

    – Stan
    Nov 20 '18 at 17:46














0












0








0








I have a simple SQL Query. However, the query has a where filter which takes a list.



The list contains at least 2000 items and it is becoming extremely inconvenient to put the long list into the query itself.



I was trying to find if I can create a table/ file and call that into the query instead.



EXAMPLE CODE:



Select * from Table_XXXX where  aa = 'yy'  and date > zzz  and mylist = [..............]


So instead of the list above, I will like to call the file (locally) in which the elements of the list reside or a table (locally and not in the database) in which the elements are in a column...



Any help will be appreciated.










share|improve this question
















I have a simple SQL Query. However, the query has a where filter which takes a list.



The list contains at least 2000 items and it is becoming extremely inconvenient to put the long list into the query itself.



I was trying to find if I can create a table/ file and call that into the query instead.



EXAMPLE CODE:



Select * from Table_XXXX where  aa = 'yy'  and date > zzz  and mylist = [..............]


So instead of the list above, I will like to call the file (locally) in which the elements of the list reside or a table (locally and not in the database) in which the elements are in a column...



Any help will be appreciated.







mysql sql pandas filter sql-like






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 6:39









Srce Cde

1,144511




1,144511










asked Nov 20 '18 at 5:02









StanStan

426




426













  • At that point it's probably best to put all the items into a temporary table and use it as a subquery with IN or EXISTS, or as part of a join.

    – Shawn
    Nov 20 '18 at 5:09













  • Neither of your preferred options are possible in mysql , I don't know about pandas.

    – P.Salmon
    Nov 20 '18 at 7:39











  • As far as creating a table how can I call a local table and not a table in the database?

    – Stan
    Nov 20 '18 at 17:46



















  • At that point it's probably best to put all the items into a temporary table and use it as a subquery with IN or EXISTS, or as part of a join.

    – Shawn
    Nov 20 '18 at 5:09













  • Neither of your preferred options are possible in mysql , I don't know about pandas.

    – P.Salmon
    Nov 20 '18 at 7:39











  • As far as creating a table how can I call a local table and not a table in the database?

    – Stan
    Nov 20 '18 at 17:46

















At that point it's probably best to put all the items into a temporary table and use it as a subquery with IN or EXISTS, or as part of a join.

– Shawn
Nov 20 '18 at 5:09







At that point it's probably best to put all the items into a temporary table and use it as a subquery with IN or EXISTS, or as part of a join.

– Shawn
Nov 20 '18 at 5:09















Neither of your preferred options are possible in mysql , I don't know about pandas.

– P.Salmon
Nov 20 '18 at 7:39





Neither of your preferred options are possible in mysql , I don't know about pandas.

– P.Salmon
Nov 20 '18 at 7:39













As far as creating a table how can I call a local table and not a table in the database?

– Stan
Nov 20 '18 at 17:46





As far as creating a table how can I call a local table and not a table in the database?

– Stan
Nov 20 '18 at 17:46












1 Answer
1






active

oldest

votes


















0














First you would store the contents of the file/list in a table. And after that you can use the in condition



create table mylist(x int);
insert into mylist values(<all values in your file>);

select *
from Table_XXXX tt
where tt.aa = 'yy'
and tt.date > zzz
and tt.mylist IN (select x from mylist)





share|improve this answer
























  • Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

    – Stan
    Nov 20 '18 at 14:17











  • Perhaps i didnt get it correct. is "mylist" a table?

    – George Joseph
    Nov 20 '18 at 14:29











  • I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

    – Stan
    Nov 20 '18 at 14:52











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386509%2fgetting-the-input-list-of-a-where-in-filter-for-sql-query-from-a-file-or-a-local%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














First you would store the contents of the file/list in a table. And after that you can use the in condition



create table mylist(x int);
insert into mylist values(<all values in your file>);

select *
from Table_XXXX tt
where tt.aa = 'yy'
and tt.date > zzz
and tt.mylist IN (select x from mylist)





share|improve this answer
























  • Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

    – Stan
    Nov 20 '18 at 14:17











  • Perhaps i didnt get it correct. is "mylist" a table?

    – George Joseph
    Nov 20 '18 at 14:29











  • I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

    – Stan
    Nov 20 '18 at 14:52
















0














First you would store the contents of the file/list in a table. And after that you can use the in condition



create table mylist(x int);
insert into mylist values(<all values in your file>);

select *
from Table_XXXX tt
where tt.aa = 'yy'
and tt.date > zzz
and tt.mylist IN (select x from mylist)





share|improve this answer
























  • Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

    – Stan
    Nov 20 '18 at 14:17











  • Perhaps i didnt get it correct. is "mylist" a table?

    – George Joseph
    Nov 20 '18 at 14:29











  • I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

    – Stan
    Nov 20 '18 at 14:52














0












0








0







First you would store the contents of the file/list in a table. And after that you can use the in condition



create table mylist(x int);
insert into mylist values(<all values in your file>);

select *
from Table_XXXX tt
where tt.aa = 'yy'
and tt.date > zzz
and tt.mylist IN (select x from mylist)





share|improve this answer













First you would store the contents of the file/list in a table. And after that you can use the in condition



create table mylist(x int);
insert into mylist values(<all values in your file>);

select *
from Table_XXXX tt
where tt.aa = 'yy'
and tt.date > zzz
and tt.mylist IN (select x from mylist)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 5:10









George JosephGeorge Joseph

1,44249




1,44249













  • Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

    – Stan
    Nov 20 '18 at 14:17











  • Perhaps i didnt get it correct. is "mylist" a table?

    – George Joseph
    Nov 20 '18 at 14:29











  • I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

    – Stan
    Nov 20 '18 at 14:52



















  • Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

    – Stan
    Nov 20 '18 at 14:17











  • Perhaps i didnt get it correct. is "mylist" a table?

    – George Joseph
    Nov 20 '18 at 14:29











  • I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

    – Stan
    Nov 20 '18 at 14:52

















Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

– Stan
Nov 20 '18 at 14:17





Thanks George. However, I did not get the second line.. Is the insert into my list a function in sql? How can I get the values from file->table->list. Sorry for my ignorance.

– Stan
Nov 20 '18 at 14:17













Perhaps i didnt get it correct. is "mylist" a table?

– George Joseph
Nov 20 '18 at 14:29





Perhaps i didnt get it correct. is "mylist" a table?

– George Joseph
Nov 20 '18 at 14:29













I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

– Stan
Nov 20 '18 at 14:52





I have a file with a column which I want to put as a filter for SQL Query as WHERE IN (....).. So now the next parts I am not sure how to deal with.. Thanks

– Stan
Nov 20 '18 at 14:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386509%2fgetting-the-input-list-of-a-where-in-filter-for-sql-query-from-a-file-or-a-local%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]