Delete a row from resultset in sqlPerforming a query on a result from another query?How can I prevent SQL injection in PHP?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to concatenate text from multiple rows into a single text string in SQL server?SQL select join: is it possible to prefix all columns as 'prefix.*'?Inserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Finding duplicate values in a SQL tableWhat are the options for storing hierarchical data in a relational database?How to Delete using INNER JOIN with SQL Server?
Remove ads in Viber for PC
Calculate Landau's function
How did Gollum know Sauron was gathering the Haradrim to make war?
Some questions about Lightning and Tor
How Powerful a Starship Coilgun Can We Make?
Meaning of "educating the ice"
Map a function that takes arguments in different levels of a list
How do I get my neighbour to stop disturbing with loud music?
Why would a Intel 8080 chip be destroyed if +12 V is connected before -5 V?
Why does dough containing a small amount of terumah become exempt from challah?
Are there consequences for not filing a DMCA (any country)
When making yogurt, why doesn't bad bacteria grow as well?
In mathematics is there a substitution that is "different" from Vieta's substitution to solve the cubic equation?
What happens if you just start drawing from the Deck of Many Things without declaring any number of cards?
Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code
Function of the separated, individual solar cells on Telstar 1 and 2? Why were they "special"?
Do we know the problems the University of Manchester's Transistor Computer was intended to solve?
Heuristic argument for the Riemann Hypothesis
Why don't they build airplanes from 3D printer plastic?
Why do old games use flashing as means of showing damage?
How to check status of Wi-Fi adapter through command line?
Why didn't Thatcher give Hong Kong to Taiwan?
Updating multiple vector points at once with vertex editor in QGIS?
If the government illegally doesn't ask for article 50 extension, can parliament do it instead?
Delete a row from resultset in sql
Performing a query on a result from another query?How can I prevent SQL injection in PHP?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to concatenate text from multiple rows into a single text string in SQL server?SQL select join: is it possible to prefix all columns as 'prefix.*'?Inserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Finding duplicate values in a SQL tableWhat are the options for storing hierarchical data in a relational database?How to Delete using INNER JOIN with SQL Server?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to run the below query. for a reason i need to join different tables which includes the results from all tables.
Let's say the query is :
Select a.value1, b.value2, c.value3
from a
join b on a.some_value = b.some_value1
join c on c.Some_other_value = b.some_diff_value
where (my conditions)...
Let's say the result of the above query is :
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
2 | othr1 | othr2
3 | diff2 | diff3
I want to remove the values from the above result set which value1 is not 1.
Expected output:
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
Is there any way in postgresql that I can achieve this? Searched for different threads but no clue in any other posts. Any suggestions are appreciated.
Note: I cannot use where a.value1 = 1 as the logic in the SQL query will result in losing some records for doing math. So the whole idea is to run the SQL query as is but to remove the records after the Select operation is done and just have the result with value1 = 1.
sql postgresql join sql-delete
add a comment |
I am trying to run the below query. for a reason i need to join different tables which includes the results from all tables.
Let's say the query is :
Select a.value1, b.value2, c.value3
from a
join b on a.some_value = b.some_value1
join c on c.Some_other_value = b.some_diff_value
where (my conditions)...
Let's say the result of the above query is :
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
2 | othr1 | othr2
3 | diff2 | diff3
I want to remove the values from the above result set which value1 is not 1.
Expected output:
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
Is there any way in postgresql that I can achieve this? Searched for different threads but no clue in any other posts. Any suggestions are appreciated.
Note: I cannot use where a.value1 = 1 as the logic in the SQL query will result in losing some records for doing math. So the whole idea is to run the SQL query as is but to remove the records after the Select operation is done and just have the result with value1 = 1.
sql postgresql join sql-delete
1
Read re subqueries. PS This is obviously a duplicate, but I didn't easily find one. Before considering posting please always google any error message and/or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names, & read many answers. If you post a question, use one phrasing as title. How to Ask That usually involves many synonyms for overloaded words, like remove or filter instead of delete, or query result instead of resultset. PS Please put stuff like what follows "So the whole idea is ..." at the beginning. It could be the whole post.
– philipxy
Mar 28 at 3:37
Possible duplicate of Performing a query on a result from another query?
– philipxy
Mar 28 at 3:55
add a comment |
I am trying to run the below query. for a reason i need to join different tables which includes the results from all tables.
Let's say the query is :
Select a.value1, b.value2, c.value3
from a
join b on a.some_value = b.some_value1
join c on c.Some_other_value = b.some_diff_value
where (my conditions)...
Let's say the result of the above query is :
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
2 | othr1 | othr2
3 | diff2 | diff3
I want to remove the values from the above result set which value1 is not 1.
Expected output:
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
Is there any way in postgresql that I can achieve this? Searched for different threads but no clue in any other posts. Any suggestions are appreciated.
Note: I cannot use where a.value1 = 1 as the logic in the SQL query will result in losing some records for doing math. So the whole idea is to run the SQL query as is but to remove the records after the Select operation is done and just have the result with value1 = 1.
sql postgresql join sql-delete
I am trying to run the below query. for a reason i need to join different tables which includes the results from all tables.
Let's say the query is :
Select a.value1, b.value2, c.value3
from a
join b on a.some_value = b.some_value1
join c on c.Some_other_value = b.some_diff_value
where (my conditions)...
Let's say the result of the above query is :
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
2 | othr1 | othr2
3 | diff2 | diff3
I want to remove the values from the above result set which value1 is not 1.
Expected output:
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
Is there any way in postgresql that I can achieve this? Searched for different threads but no clue in any other posts. Any suggestions are appreciated.
Note: I cannot use where a.value1 = 1 as the logic in the SQL query will result in losing some records for doing math. So the whole idea is to run the SQL query as is but to remove the records after the Select operation is done and just have the result with value1 = 1.
sql postgresql join sql-delete
sql postgresql join sql-delete
edited Mar 28 at 4:58
marc_s
603k136 gold badges1152 silver badges1289 bronze badges
603k136 gold badges1152 silver badges1289 bronze badges
asked Mar 28 at 1:52
gingging
476 bronze badges
476 bronze badges
1
Read re subqueries. PS This is obviously a duplicate, but I didn't easily find one. Before considering posting please always google any error message and/or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names, & read many answers. If you post a question, use one phrasing as title. How to Ask That usually involves many synonyms for overloaded words, like remove or filter instead of delete, or query result instead of resultset. PS Please put stuff like what follows "So the whole idea is ..." at the beginning. It could be the whole post.
– philipxy
Mar 28 at 3:37
Possible duplicate of Performing a query on a result from another query?
– philipxy
Mar 28 at 3:55
add a comment |
1
Read re subqueries. PS This is obviously a duplicate, but I didn't easily find one. Before considering posting please always google any error message and/or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names, & read many answers. If you post a question, use one phrasing as title. How to Ask That usually involves many synonyms for overloaded words, like remove or filter instead of delete, or query result instead of resultset. PS Please put stuff like what follows "So the whole idea is ..." at the beginning. It could be the whole post.
– philipxy
Mar 28 at 3:37
Possible duplicate of Performing a query on a result from another query?
– philipxy
Mar 28 at 3:55
1
1
Read re subqueries. PS This is obviously a duplicate, but I didn't easily find one. Before considering posting please always google any error message and/or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names, & read many answers. If you post a question, use one phrasing as title. How to Ask That usually involves many synonyms for overloaded words, like remove or filter instead of delete, or query result instead of resultset. PS Please put stuff like what follows "So the whole idea is ..." at the beginning. It could be the whole post.
– philipxy
Mar 28 at 3:37
Read re subqueries. PS This is obviously a duplicate, but I didn't easily find one. Before considering posting please always google any error message and/or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names, & read many answers. If you post a question, use one phrasing as title. How to Ask That usually involves many synonyms for overloaded words, like remove or filter instead of delete, or query result instead of resultset. PS Please put stuff like what follows "So the whole idea is ..." at the beginning. It could be the whole post.
– philipxy
Mar 28 at 3:37
Possible duplicate of Performing a query on a result from another query?
– philipxy
Mar 28 at 3:55
Possible duplicate of Performing a query on a result from another query?
– philipxy
Mar 28 at 3:55
add a comment |
1 Answer
1
active
oldest
votes
use subquery and then filter out a.value1=1 in where clause
select * from
(
Select a.value1,b.value2,c.value3
from a join b on a.some_value=b.some_value1
join c on c.Some_othr_value=b.some_diff_value
where your conditions
)AA where a.value1=1
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
1
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
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%2f55389041%2fdelete-a-row-from-resultset-in-sql%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
use subquery and then filter out a.value1=1 in where clause
select * from
(
Select a.value1,b.value2,c.value3
from a join b on a.some_value=b.some_value1
join c on c.Some_othr_value=b.some_diff_value
where your conditions
)AA where a.value1=1
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
1
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
add a comment |
use subquery and then filter out a.value1=1 in where clause
select * from
(
Select a.value1,b.value2,c.value3
from a join b on a.some_value=b.some_value1
join c on c.Some_othr_value=b.some_diff_value
where your conditions
)AA where a.value1=1
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
1
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
add a comment |
use subquery and then filter out a.value1=1 in where clause
select * from
(
Select a.value1,b.value2,c.value3
from a join b on a.some_value=b.some_value1
join c on c.Some_othr_value=b.some_diff_value
where your conditions
)AA where a.value1=1
use subquery and then filter out a.value1=1 in where clause
select * from
(
Select a.value1,b.value2,c.value3
from a join b on a.some_value=b.some_value1
join c on c.Some_othr_value=b.some_diff_value
where your conditions
)AA where a.value1=1
edited Mar 28 at 1:58
answered Mar 28 at 1:54
fa06fa06
24.6k5 gold badges11 silver badges20 bronze badges
24.6k5 gold badges11 silver badges20 bronze badges
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
1
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
add a comment |
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
1
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
Nope. Sorry if i am not clear in the question. I cannot use a.value1=1 here as it will eliminate some logic in the joins. @fa06
– ging
Mar 28 at 1:56
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
@ging, updated this with subquery - u can check
– fa06
Mar 28 at 1:58
1
1
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
@Perfect. Will accept the answer as soon as i can. Can accept this after 6min. Thanks for the quick response.
– ging
Mar 28 at 2:00
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55389041%2fdelete-a-row-from-resultset-in-sql%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
1
Read re subqueries. PS This is obviously a duplicate, but I didn't easily find one. Before considering posting please always google any error message and/or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names, & read many answers. If you post a question, use one phrasing as title. How to Ask That usually involves many synonyms for overloaded words, like remove or filter instead of delete, or query result instead of resultset. PS Please put stuff like what follows "So the whole idea is ..." at the beginning. It could be the whole post.
– philipxy
Mar 28 at 3:37
Possible duplicate of Performing a query on a result from another query?
– philipxy
Mar 28 at 3:55