SQL Statement using WHERE with 2 lists depending on each otherSQL List Products that are Not Already OrderedSelect certain row based on my conditionFinding Non Matches in SQL StatementAn sql query to get small qty value from a list of productsMysql left join and nullSQL to return product and product dependenciesCASE/WHEN in WHERE condition depending on row indexsame SQL subquery with WHERE and FROMSql left inner join + where causes (closed)Combining multiple SQL SELECT statements into one

Is oxalic acid dihydrate considered a primary acid standard in analytical chemistry?

Anatomically Correct Strange Women In Ponds Distributing Swords

Inappropriate reference requests from Journal reviewers

How do we know the LHC results are robust?

System.debug(JSON.Serialize(o)) Not longer shows full string

Valid Badminton Score?

Large drywall patch supports

How did Doctor Strange see the winning outcome in Avengers: Infinity War?

Is exact Kanji stroke length important?

Opposite of a diet

Is there a problem with hiding "forgot password" until it's needed?

when is out of tune ok?

Is there a good way to store credentials outside of a password manager?

Go Pregnant or Go Home

Would a high gravity rocky planet be guaranteed to have an atmosphere?

Why not increase contact surface when reentering the atmosphere?

Return the Closest Prime Number

How to check is there any negative term in a large list?

Is expanding the research of a group into machine learning as a PhD student risky?

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

How can a function with a hole (removable discontinuity) equal a function with no hole?

How to Reset Passwords on Multiple Websites Easily?

Why escape if the_content isnt?

How long to clear the 'suck zone' of a turbofan after start is initiated?



SQL Statement using WHERE with 2 lists depending on each other


SQL List Products that are Not Already OrderedSelect certain row based on my conditionFinding Non Matches in SQL StatementAn sql query to get small qty value from a list of productsMysql left join and nullSQL to return product and product dependenciesCASE/WHEN in WHERE condition depending on row indexsame SQL subquery with WHERE and FROMSql left inner join + where causes (closed)Combining multiple SQL SELECT statements into one













0















I have 2 huge tables of products and specifications and let's say I need to get/update 40 of them. I am trying to use those lists like



first list->row == second list->row



My SQL looks like this



SELECT * FROM product JOIN specification ON product.id_product = spceification.product_id WHERE product.id_product IN (1592,1593,16062,1615)
AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)


Now it returns so many results because some other products with different ID has this suffix. So I need only returns:



1592 + E-150,
1593 + E-100,
16062 + 0-PLUS,
1615 + NULL


Basically I need something like this (below) but I though I can do it with 2 lists (this solution below does not work either, it has some kind of error):



SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
(product.id_product = 1592 AND specification.suffix = E-150),
(product.id_product = 1593 AND specification.suffix = E-100),
...


If you understand me (sorry I have really bad english and explaining skills). Thank you for any tips!










share|improve this question
























  • The , in your WHERE clause should be OR, other than that it should work fine

    – Nick
    Mar 8 at 11:43











  • Note that for your last case you will need to use (product.id_product = 1615 AND specification.suffix IS NULL)

    – Nick
    Mar 8 at 11:43











  • Can you please give the column names instead of * so that i write query in a more better way. To be more specific only the column name for which the value will be unique.

    – blueDexter
    Mar 8 at 11:58
















0















I have 2 huge tables of products and specifications and let's say I need to get/update 40 of them. I am trying to use those lists like



first list->row == second list->row



My SQL looks like this



SELECT * FROM product JOIN specification ON product.id_product = spceification.product_id WHERE product.id_product IN (1592,1593,16062,1615)
AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)


Now it returns so many results because some other products with different ID has this suffix. So I need only returns:



1592 + E-150,
1593 + E-100,
16062 + 0-PLUS,
1615 + NULL


Basically I need something like this (below) but I though I can do it with 2 lists (this solution below does not work either, it has some kind of error):



SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
(product.id_product = 1592 AND specification.suffix = E-150),
(product.id_product = 1593 AND specification.suffix = E-100),
...


If you understand me (sorry I have really bad english and explaining skills). Thank you for any tips!










share|improve this question
























  • The , in your WHERE clause should be OR, other than that it should work fine

    – Nick
    Mar 8 at 11:43











  • Note that for your last case you will need to use (product.id_product = 1615 AND specification.suffix IS NULL)

    – Nick
    Mar 8 at 11:43











  • Can you please give the column names instead of * so that i write query in a more better way. To be more specific only the column name for which the value will be unique.

    – blueDexter
    Mar 8 at 11:58














0












0








0








I have 2 huge tables of products and specifications and let's say I need to get/update 40 of them. I am trying to use those lists like



first list->row == second list->row



My SQL looks like this



SELECT * FROM product JOIN specification ON product.id_product = spceification.product_id WHERE product.id_product IN (1592,1593,16062,1615)
AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)


Now it returns so many results because some other products with different ID has this suffix. So I need only returns:



1592 + E-150,
1593 + E-100,
16062 + 0-PLUS,
1615 + NULL


Basically I need something like this (below) but I though I can do it with 2 lists (this solution below does not work either, it has some kind of error):



SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
(product.id_product = 1592 AND specification.suffix = E-150),
(product.id_product = 1593 AND specification.suffix = E-100),
...


If you understand me (sorry I have really bad english and explaining skills). Thank you for any tips!










share|improve this question
















I have 2 huge tables of products and specifications and let's say I need to get/update 40 of them. I am trying to use those lists like



first list->row == second list->row



My SQL looks like this



SELECT * FROM product JOIN specification ON product.id_product = spceification.product_id WHERE product.id_product IN (1592,1593,16062,1615)
AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)


Now it returns so many results because some other products with different ID has this suffix. So I need only returns:



1592 + E-150,
1593 + E-100,
16062 + 0-PLUS,
1615 + NULL


Basically I need something like this (below) but I though I can do it with 2 lists (this solution below does not work either, it has some kind of error):



SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
(product.id_product = 1592 AND specification.suffix = E-150),
(product.id_product = 1593 AND specification.suffix = E-100),
...


If you understand me (sorry I have really bad english and explaining skills). Thank you for any tips!







mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 11:39







John K.

















asked Mar 8 at 11:34









John K.John K.

146




146












  • The , in your WHERE clause should be OR, other than that it should work fine

    – Nick
    Mar 8 at 11:43











  • Note that for your last case you will need to use (product.id_product = 1615 AND specification.suffix IS NULL)

    – Nick
    Mar 8 at 11:43











  • Can you please give the column names instead of * so that i write query in a more better way. To be more specific only the column name for which the value will be unique.

    – blueDexter
    Mar 8 at 11:58


















  • The , in your WHERE clause should be OR, other than that it should work fine

    – Nick
    Mar 8 at 11:43











  • Note that for your last case you will need to use (product.id_product = 1615 AND specification.suffix IS NULL)

    – Nick
    Mar 8 at 11:43











  • Can you please give the column names instead of * so that i write query in a more better way. To be more specific only the column name for which the value will be unique.

    – blueDexter
    Mar 8 at 11:58

















The , in your WHERE clause should be OR, other than that it should work fine

– Nick
Mar 8 at 11:43





The , in your WHERE clause should be OR, other than that it should work fine

– Nick
Mar 8 at 11:43













Note that for your last case you will need to use (product.id_product = 1615 AND specification.suffix IS NULL)

– Nick
Mar 8 at 11:43





Note that for your last case you will need to use (product.id_product = 1615 AND specification.suffix IS NULL)

– Nick
Mar 8 at 11:43













Can you please give the column names instead of * so that i write query in a more better way. To be more specific only the column name for which the value will be unique.

– blueDexter
Mar 8 at 11:58






Can you please give the column names instead of * so that i write query in a more better way. To be more specific only the column name for which the value will be unique.

– blueDexter
Mar 8 at 11:58













2 Answers
2






active

oldest

votes


















0














Your second query is almost spot-on. You were very close there :)



Try changing the commas by OR



SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
(product.id_product = 1592 AND specification.suffix = E-150) OR
(product.id_product = 1593 AND specification.suffix = E-100)





share|improve this answer


















  • 1





    Works like a charm! Thank you very much!

    – John K.
    Mar 8 at 14:58


















0














You can try like below-



select * from 
(
SELECT * FROM product JOIN specification
ON product.id_product = spceification.product_id
WHERE product.id_product IN (1592,1593,16062,1615) AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)
)A WHERE (id_product, suffix) IN ( (1592 , 'E-150'), (1593 ,'E-100') )





share|improve this answer






















    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%2f55062415%2fsql-statement-using-where-with-2-lists-depending-on-each-other%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Your second query is almost spot-on. You were very close there :)



    Try changing the commas by OR



    SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
    (product.id_product = 1592 AND specification.suffix = E-150) OR
    (product.id_product = 1593 AND specification.suffix = E-100)





    share|improve this answer


















    • 1





      Works like a charm! Thank you very much!

      – John K.
      Mar 8 at 14:58















    0














    Your second query is almost spot-on. You were very close there :)



    Try changing the commas by OR



    SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
    (product.id_product = 1592 AND specification.suffix = E-150) OR
    (product.id_product = 1593 AND specification.suffix = E-100)





    share|improve this answer


















    • 1





      Works like a charm! Thank you very much!

      – John K.
      Mar 8 at 14:58













    0












    0








    0







    Your second query is almost spot-on. You were very close there :)



    Try changing the commas by OR



    SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
    (product.id_product = 1592 AND specification.suffix = E-150) OR
    (product.id_product = 1593 AND specification.suffix = E-100)





    share|improve this answer













    Your second query is almost spot-on. You were very close there :)



    Try changing the commas by OR



    SELECT * FROM product JOIN specification.product_id = product.id_product WHERE 
    (product.id_product = 1592 AND specification.suffix = E-150) OR
    (product.id_product = 1593 AND specification.suffix = E-100)






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 8 at 11:47









    Javier RamirezJavier Ramirez

    1,8531022




    1,8531022







    • 1





      Works like a charm! Thank you very much!

      – John K.
      Mar 8 at 14:58












    • 1





      Works like a charm! Thank you very much!

      – John K.
      Mar 8 at 14:58







    1




    1





    Works like a charm! Thank you very much!

    – John K.
    Mar 8 at 14:58





    Works like a charm! Thank you very much!

    – John K.
    Mar 8 at 14:58













    0














    You can try like below-



    select * from 
    (
    SELECT * FROM product JOIN specification
    ON product.id_product = spceification.product_id
    WHERE product.id_product IN (1592,1593,16062,1615) AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)
    )A WHERE (id_product, suffix) IN ( (1592 , 'E-150'), (1593 ,'E-100') )





    share|improve this answer



























      0














      You can try like below-



      select * from 
      (
      SELECT * FROM product JOIN specification
      ON product.id_product = spceification.product_id
      WHERE product.id_product IN (1592,1593,16062,1615) AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)
      )A WHERE (id_product, suffix) IN ( (1592 , 'E-150'), (1593 ,'E-100') )





      share|improve this answer

























        0












        0








        0







        You can try like below-



        select * from 
        (
        SELECT * FROM product JOIN specification
        ON product.id_product = spceification.product_id
        WHERE product.id_product IN (1592,1593,16062,1615) AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)
        )A WHERE (id_product, suffix) IN ( (1592 , 'E-150'), (1593 ,'E-100') )





        share|improve this answer













        You can try like below-



        select * from 
        (
        SELECT * FROM product JOIN specification
        ON product.id_product = spceification.product_id
        WHERE product.id_product IN (1592,1593,16062,1615) AND specification.suffix IN ('E-150','E-100','0-PLUS',NULL)
        )A WHERE (id_product, suffix) IN ( (1592 , 'E-150'), (1593 ,'E-100') )






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 11:43









        fa06fa06

        18.1k21018




        18.1k21018



























            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%2f55062415%2fsql-statement-using-where-with-2-lists-depending-on-each-other%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

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page