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
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
add a comment |
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
The,
in yourWHERE
clause should beOR
, 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
add a comment |
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
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
mysql
edited Mar 8 at 11:39
John K.
asked Mar 8 at 11:34
John K.John K.
146
146
The,
in yourWHERE
clause should beOR
, 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
add a comment |
The,
in yourWHERE
clause should beOR
, 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
add a comment |
2 Answers
2
active
oldest
votes
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)
1
Works like a charm! Thank you very much!
– John K.
Mar 8 at 14:58
add a comment |
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') )
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
1
Works like a charm! Thank you very much!
– John K.
Mar 8 at 14:58
add a comment |
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)
1
Works like a charm! Thank you very much!
– John K.
Mar 8 at 14:58
add a comment |
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)
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)
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
add a comment |
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
add a comment |
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') )
add a comment |
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') )
add a comment |
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') )
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') )
answered Mar 8 at 11:43
fa06fa06
18.1k21018
18.1k21018
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
The
,
in yourWHERE
clause should beOR
, 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