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

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived