Fetch data of two tables with/without match of Primary key and foreign key Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Can I concatenate multiple MySQL rows into one field?SQL Server: How to Join to first rowWhat are the options for storing hierarchical data in a relational database?How to select rows with no matching entry in another table?Delete all Duplicate Rows except for One in MySQL?Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraintsSQL select only rows with max value on a columnSelect last record for each foreign key that match primary keyError no primary key in a table with two foreign keyHow to match multiple tables foreign keys to another tables primary key
What would you call this weird metallic apparatus that allows you to lift people?
What does it mean that physics no longer uses mechanical models to describe phenomena?
A term for a woman complaining about things/begging in a cute/childish way
What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?
Why do early math courses focus on the cross sections of a cone and not on other 3D objects?
What do you call the main part of a joke?
Putting class ranking in CV, but against dept guidelines
Is there hard evidence that the grant peer review system performs significantly better than random?
How to tell that you are a giant?
Disembodied hand growing fangs
How much damage would a cupful of neutron star matter do to the Earth?
How come Sam didn't become Lord of Horn Hill?
Can a new player join a group only when a new campaign starts?
Why should I vote and accept answers?
How to write the following sign?
Crossing US/Canada Border for less than 24 hours
How to play a character with a disability or mental disorder without being offensive?
How does the secondary effect of the Heat Metal spell interact with a creature resistant/immune to fire damage?
SF book about people trapped in a series of worlds they imagine
Did Deadpool rescue all of the X-Force?
Effects on objects due to a brief relocation of massive amounts of mass
Why weren't discrete x86 CPUs ever used in game hardware?
Why does the remaining Rebel fleet at the end of Rogue One seem dramatically larger than the one in A New Hope?
An adverb for when you're not exaggerating
Fetch data of two tables with/without match of Primary key and foreign key
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Can I concatenate multiple MySQL rows into one field?SQL Server: How to Join to first rowWhat are the options for storing hierarchical data in a relational database?How to select rows with no matching entry in another table?Delete all Duplicate Rows except for One in MySQL?Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraintsSQL select only rows with max value on a columnSelect last record for each foreign key that match primary keyError no primary key in a table with two foreign keyHow to match multiple tables foreign keys to another tables primary key
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am using this query.
select * from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
Here E.ID is primary key of customers table and p_ID is foreign key of customer_p
This query fetches only those result in which primary key (ID) of customers table is present as foreign key (P__ID) of customer_p table and skips rest rows/data from customers table.
I want to fetch all date of customers table whether or not primary key (ID) do match with foreign key (P__ID). How can I do this?
php sql
add a comment |
I am using this query.
select * from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
Here E.ID is primary key of customers table and p_ID is foreign key of customer_p
This query fetches only those result in which primary key (ID) of customers table is present as foreign key (P__ID) of customer_p table and skips rest rows/data from customers table.
I want to fetch all date of customers table whether or not primary key (ID) do match with foreign key (P__ID). How can I do this?
php sql
1
That is why there is aLeft Join
– ArtisticPhoenix
Mar 22 at 9:55
1
I dont know, if I understand correctly, but try LEFT JOIN ->select * from customers E LEFT JOIN customer_p D ON (E.ID = D.P_ID)
– Autista_z
Mar 22 at 9:55
add a comment |
I am using this query.
select * from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
Here E.ID is primary key of customers table and p_ID is foreign key of customer_p
This query fetches only those result in which primary key (ID) of customers table is present as foreign key (P__ID) of customer_p table and skips rest rows/data from customers table.
I want to fetch all date of customers table whether or not primary key (ID) do match with foreign key (P__ID). How can I do this?
php sql
I am using this query.
select * from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
Here E.ID is primary key of customers table and p_ID is foreign key of customer_p
This query fetches only those result in which primary key (ID) of customers table is present as foreign key (P__ID) of customer_p table and skips rest rows/data from customers table.
I want to fetch all date of customers table whether or not primary key (ID) do match with foreign key (P__ID). How can I do this?
php sql
php sql
asked Mar 22 at 9:52
RishabhRishabh
3102618
3102618
1
That is why there is aLeft Join
– ArtisticPhoenix
Mar 22 at 9:55
1
I dont know, if I understand correctly, but try LEFT JOIN ->select * from customers E LEFT JOIN customer_p D ON (E.ID = D.P_ID)
– Autista_z
Mar 22 at 9:55
add a comment |
1
That is why there is aLeft Join
– ArtisticPhoenix
Mar 22 at 9:55
1
I dont know, if I understand correctly, but try LEFT JOIN ->select * from customers E LEFT JOIN customer_p D ON (E.ID = D.P_ID)
– Autista_z
Mar 22 at 9:55
1
1
That is why there is a
Left Join
– ArtisticPhoenix
Mar 22 at 9:55
That is why there is a
Left Join
– ArtisticPhoenix
Mar 22 at 9:55
1
1
I dont know, if I understand correctly, but try LEFT JOIN ->
select * from customers E LEFT JOIN customer_p D ON (E.ID = D.P_ID)
– Autista_z
Mar 22 at 9:55
I dont know, if I understand correctly, but try LEFT JOIN ->
select * from customers E LEFT JOIN customer_p D ON (E.ID = D.P_ID)
– Autista_z
Mar 22 at 9:55
add a comment |
3 Answers
3
active
oldest
votes
Use LEFT JOIN instead of JOIN to get all rows in customers.
see https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
add a comment |
Please run below query:
SELECT E.*, D.*
FROM customers as E
LEFT JOIN `customer_p` as D ON D.P_ID = E.ID
add a comment |
select date from customers where not
(
select date from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
)
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
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%2f55296971%2ffetch-data-of-two-tables-with-without-match-of-primary-key-and-foreign-key%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use LEFT JOIN instead of JOIN to get all rows in customers.
see https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
add a comment |
Use LEFT JOIN instead of JOIN to get all rows in customers.
see https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
add a comment |
Use LEFT JOIN instead of JOIN to get all rows in customers.
see https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
Use LEFT JOIN instead of JOIN to get all rows in customers.
see https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
answered Mar 22 at 9:59
vr138vr138
511
511
add a comment |
add a comment |
Please run below query:
SELECT E.*, D.*
FROM customers as E
LEFT JOIN `customer_p` as D ON D.P_ID = E.ID
add a comment |
Please run below query:
SELECT E.*, D.*
FROM customers as E
LEFT JOIN `customer_p` as D ON D.P_ID = E.ID
add a comment |
Please run below query:
SELECT E.*, D.*
FROM customers as E
LEFT JOIN `customer_p` as D ON D.P_ID = E.ID
Please run below query:
SELECT E.*, D.*
FROM customers as E
LEFT JOIN `customer_p` as D ON D.P_ID = E.ID
edited Apr 1 at 3:33
Rich
1,73271831
1,73271831
answered Mar 22 at 10:05
PuneetPuneet
12
12
add a comment |
add a comment |
select date from customers where not
(
select date from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
)
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
add a comment |
select date from customers where not
(
select date from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
)
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
add a comment |
select date from customers where not
(
select date from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
)
select date from customers where not
(
select date from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
)
answered Mar 22 at 9:56
esnkrimiesnkrimi
883
883
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
add a comment |
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
Please add some explanation to your query such that others can learn from it
– Nico Haase
Mar 22 at 10:19
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%2f55296971%2ffetch-data-of-two-tables-with-without-match-of-primary-key-and-foreign-key%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
That is why there is a
Left Join
– ArtisticPhoenix
Mar 22 at 9:55
1
I dont know, if I understand correctly, but try LEFT JOIN ->
select * from customers E LEFT JOIN customer_p D ON (E.ID = D.P_ID)
– Autista_z
Mar 22 at 9:55