Need to Combine two mysql select queries into one efficientlyHow to get non-deleted messages for one user_id...
Does red noise even at low values mean a hardware problem with my camera's sensor?
Does copper wire need to say it's copper?
Boss asked me to sign a resignation paper without a date on it along with my new contract
Calculating the strength of an ionic bond that contains poly-atomic ions
What is the second derivative with respect to price of a put option?
How can I handle players killing my NPC outside of combat?
Sri Keyuravati of krama tradition
In a post-apocalypse world, with no power and few survivors, would Satnav still work?
How do I narratively explain how in-game circumstances do not mechanically allow a PC to instantly kill an NPC?
Do the speed limit reductions due to pollution also apply to electric cars in France?
Renting a 2CV in France
In the Lost in Space intro why was Dr. Smith actor listed as a special guest star?
How can I prevent an oracle who can see into the past from knowing everything that has happened?
Sticky Strike or Sticky Delta
Coworker asking me to not bring cakes due to self control issue. What should I do?
Even as admin, I cannot edit DefaultFonts.plist for Notes.app. What am I doing wrong?
"I showed the monkey himself in the mirror". Why is this sentence grammatical?
Is "accuse people to be racist" grammatical?
Why do objects rebound after hitting the ground?
How can guns be countered by melee combat without raw-ability or exceptional explanations?
What are some idioms that means something along the lines of "switching it up every day to not do the same thing over and over"?
Is the UK legally prevented from having another referendum on Brexit?
Is it possible to detect 100% of SQLi with a simple regex?
Why is it that Bernie Sanders is always called a "socialist"?
Need to Combine two mysql select queries into one efficiently
How to get non-deleted messages for one user_id if the same user_id appears in two tables at same time?Can I execute a prepared statement inside a MySQL SELECT?MYSQL Combine two results into onecompare results between two select queries MySQLPrivilege to select only user's own tuple only in mysqlHelp combining two MySQL queries to improve performanceHow to combine “SELECT” and “REPLACE INTO” when combining two MySQL tables into another?Combine two queries to oneDoes MySQL allows incoming queries while altering a table?SQL schema for movie rating and seenlist
user
id | name
1 | A
2 | B
article
id | title | descritption
1 | wx | xyz
2 | yz | abc
article_rating
article_id(article->id) | given_by(user->id) | given_rating
1 2 4
2 1 3
saved_article
article_id(article->id) | saved_by(user->id)
1 2
I'm changing some buttons and icons depending on whether a user has rated/ saved an article or not. I'm using two select queries for that:
rated or not
SELECT given_rating as rating
FROM article_rating
WHERE given_by=? AND article_id=?
saved or not
SELECT saved_by as saved
FROM saved_article
WHERE saved_by=? AND article_id=?
So my question is how can i combine both into one mysql query efficiently??
mysql
add a comment |
user
id | name
1 | A
2 | B
article
id | title | descritption
1 | wx | xyz
2 | yz | abc
article_rating
article_id(article->id) | given_by(user->id) | given_rating
1 2 4
2 1 3
saved_article
article_id(article->id) | saved_by(user->id)
1 2
I'm changing some buttons and icons depending on whether a user has rated/ saved an article or not. I'm using two select queries for that:
rated or not
SELECT given_rating as rating
FROM article_rating
WHERE given_by=? AND article_id=?
saved or not
SELECT saved_by as saved
FROM saved_article
WHERE saved_by=? AND article_id=?
So my question is how can i combine both into one mysql query efficiently??
mysql
add a comment |
user
id | name
1 | A
2 | B
article
id | title | descritption
1 | wx | xyz
2 | yz | abc
article_rating
article_id(article->id) | given_by(user->id) | given_rating
1 2 4
2 1 3
saved_article
article_id(article->id) | saved_by(user->id)
1 2
I'm changing some buttons and icons depending on whether a user has rated/ saved an article or not. I'm using two select queries for that:
rated or not
SELECT given_rating as rating
FROM article_rating
WHERE given_by=? AND article_id=?
saved or not
SELECT saved_by as saved
FROM saved_article
WHERE saved_by=? AND article_id=?
So my question is how can i combine both into one mysql query efficiently??
mysql
user
id | name
1 | A
2 | B
article
id | title | descritption
1 | wx | xyz
2 | yz | abc
article_rating
article_id(article->id) | given_by(user->id) | given_rating
1 2 4
2 1 3
saved_article
article_id(article->id) | saved_by(user->id)
1 2
I'm changing some buttons and icons depending on whether a user has rated/ saved an article or not. I'm using two select queries for that:
rated or not
SELECT given_rating as rating
FROM article_rating
WHERE given_by=? AND article_id=?
saved or not
SELECT saved_by as saved
FROM saved_article
WHERE saved_by=? AND article_id=?
So my question is how can i combine both into one mysql query efficiently??
mysql
mysql
asked 4 mins ago
Share cornShare corn
1
1
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fdba.stackexchange.com%2fquestions%2f230611%2fneed-to-combine-two-mysql-select-queries-into-one-efficiently%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Database Administrators Stack Exchange!
- 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%2fdba.stackexchange.com%2fquestions%2f230611%2fneed-to-combine-two-mysql-select-queries-into-one-efficiently%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