How to display data using more than 2 foreign key in sql?
I have 4 tables in my database which is student, committee, event, evtstatus. I need to retrieve some data from each table.
I have already try it in mysqli still i get some errors as like
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsStudentindex.php on line 106
student:
student_id | name | member_type
10 | Ali | Not A Member
14 | James | Member of Taekwando
15 | Bakar | Not A Member
committee:
committee_id | email | image |
1 | abc@gmail.com | pic.jpg |
2 | abccd@ymail.com | pic1.jpg |
3 | shdhs@yahoo.com | pic2.jpg |
event:
event_id | event_name | start_date | committee_id |
11 | Sport Meeting | 2018-12-19 20:00:00 | 1 |
12 | Yamacha Tonite | 2018-12-18 21:00:44 | 1 |
13 | Family Gathering | 2018-12-17 22:00:44 | 3 |
evtstatus:
evt_id | event_id | student_id | status_info |
111 | 11 | 10 | Not Going |
112 | 12 | 14 | Going |
113 | 13 | 15 | Going |
The 'committee_id' in both the event and committee are the same. 'event_id' in event and evtstatus are also same.
I want to select event name, start_date, student_id, member_type, status_info which under committee_id == 1
So the query result should be (in this case)
Sport Meeting | 2018-12-19 20:00:00 | 10 | Not A Member | Not Going
Yamacha Tonite| 2018-12-18 21:00:44 | 14 | Member of Taekwando | Going
php sql mysqli
add a comment |
I have 4 tables in my database which is student, committee, event, evtstatus. I need to retrieve some data from each table.
I have already try it in mysqli still i get some errors as like
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsStudentindex.php on line 106
student:
student_id | name | member_type
10 | Ali | Not A Member
14 | James | Member of Taekwando
15 | Bakar | Not A Member
committee:
committee_id | email | image |
1 | abc@gmail.com | pic.jpg |
2 | abccd@ymail.com | pic1.jpg |
3 | shdhs@yahoo.com | pic2.jpg |
event:
event_id | event_name | start_date | committee_id |
11 | Sport Meeting | 2018-12-19 20:00:00 | 1 |
12 | Yamacha Tonite | 2018-12-18 21:00:44 | 1 |
13 | Family Gathering | 2018-12-17 22:00:44 | 3 |
evtstatus:
evt_id | event_id | student_id | status_info |
111 | 11 | 10 | Not Going |
112 | 12 | 14 | Going |
113 | 13 | 15 | Going |
The 'committee_id' in both the event and committee are the same. 'event_id' in event and evtstatus are also same.
I want to select event name, start_date, student_id, member_type, status_info which under committee_id == 1
So the query result should be (in this case)
Sport Meeting | 2018-12-19 20:00:00 | 10 | Not A Member | Not Going
Yamacha Tonite| 2018-12-18 21:00:44 | 14 | Member of Taekwando | Going
php sql mysqli
how is the code that gives the error?
– TDK
Jan 3 at 15:52
You can use SQL JOIN, I already ask a similar question. Check this out stackoverflow.com/questions/50179108/…
– Nawaraj
Jan 3 at 15:54
add a comment |
I have 4 tables in my database which is student, committee, event, evtstatus. I need to retrieve some data from each table.
I have already try it in mysqli still i get some errors as like
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsStudentindex.php on line 106
student:
student_id | name | member_type
10 | Ali | Not A Member
14 | James | Member of Taekwando
15 | Bakar | Not A Member
committee:
committee_id | email | image |
1 | abc@gmail.com | pic.jpg |
2 | abccd@ymail.com | pic1.jpg |
3 | shdhs@yahoo.com | pic2.jpg |
event:
event_id | event_name | start_date | committee_id |
11 | Sport Meeting | 2018-12-19 20:00:00 | 1 |
12 | Yamacha Tonite | 2018-12-18 21:00:44 | 1 |
13 | Family Gathering | 2018-12-17 22:00:44 | 3 |
evtstatus:
evt_id | event_id | student_id | status_info |
111 | 11 | 10 | Not Going |
112 | 12 | 14 | Going |
113 | 13 | 15 | Going |
The 'committee_id' in both the event and committee are the same. 'event_id' in event and evtstatus are also same.
I want to select event name, start_date, student_id, member_type, status_info which under committee_id == 1
So the query result should be (in this case)
Sport Meeting | 2018-12-19 20:00:00 | 10 | Not A Member | Not Going
Yamacha Tonite| 2018-12-18 21:00:44 | 14 | Member of Taekwando | Going
php sql mysqli
I have 4 tables in my database which is student, committee, event, evtstatus. I need to retrieve some data from each table.
I have already try it in mysqli still i get some errors as like
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsStudentindex.php on line 106
student:
student_id | name | member_type
10 | Ali | Not A Member
14 | James | Member of Taekwando
15 | Bakar | Not A Member
committee:
committee_id | email | image |
1 | abc@gmail.com | pic.jpg |
2 | abccd@ymail.com | pic1.jpg |
3 | shdhs@yahoo.com | pic2.jpg |
event:
event_id | event_name | start_date | committee_id |
11 | Sport Meeting | 2018-12-19 20:00:00 | 1 |
12 | Yamacha Tonite | 2018-12-18 21:00:44 | 1 |
13 | Family Gathering | 2018-12-17 22:00:44 | 3 |
evtstatus:
evt_id | event_id | student_id | status_info |
111 | 11 | 10 | Not Going |
112 | 12 | 14 | Going |
113 | 13 | 15 | Going |
The 'committee_id' in both the event and committee are the same. 'event_id' in event and evtstatus are also same.
I want to select event name, start_date, student_id, member_type, status_info which under committee_id == 1
So the query result should be (in this case)
Sport Meeting | 2018-12-19 20:00:00 | 10 | Not A Member | Not Going
Yamacha Tonite| 2018-12-18 21:00:44 | 14 | Member of Taekwando | Going
php sql mysqli
php sql mysqli
edited Jan 3 at 15:53
Jane
asked Jan 3 at 15:48
JaneJane
13
13
how is the code that gives the error?
– TDK
Jan 3 at 15:52
You can use SQL JOIN, I already ask a similar question. Check this out stackoverflow.com/questions/50179108/…
– Nawaraj
Jan 3 at 15:54
add a comment |
how is the code that gives the error?
– TDK
Jan 3 at 15:52
You can use SQL JOIN, I already ask a similar question. Check this out stackoverflow.com/questions/50179108/…
– Nawaraj
Jan 3 at 15:54
how is the code that gives the error?
– TDK
Jan 3 at 15:52
how is the code that gives the error?
– TDK
Jan 3 at 15:52
You can use SQL JOIN, I already ask a similar question. Check this out stackoverflow.com/questions/50179108/…
– Nawaraj
Jan 3 at 15:54
You can use SQL JOIN, I already ask a similar question. Check this out stackoverflow.com/questions/50179108/…
– Nawaraj
Jan 3 at 15:54
add a comment |
1 Answer
1
active
oldest
votes
Using typical JOIN
s you can do this:
select
e.event_name,
e.start_date,
es.student_id,
s.member_type,
es.status_info
from evtstatus es
join student s on s.student_id = es.student_id
join event e on e.event_id = es.event_id
join committee c on c.committee_id = e.committee_id
where e.committee_id = 1
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
add a comment |
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%2f54025585%2fhow-to-display-data-using-more-than-2-foreign-key-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
Using typical JOIN
s you can do this:
select
e.event_name,
e.start_date,
es.student_id,
s.member_type,
es.status_info
from evtstatus es
join student s on s.student_id = es.student_id
join event e on e.event_id = es.event_id
join committee c on c.committee_id = e.committee_id
where e.committee_id = 1
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
add a comment |
Using typical JOIN
s you can do this:
select
e.event_name,
e.start_date,
es.student_id,
s.member_type,
es.status_info
from evtstatus es
join student s on s.student_id = es.student_id
join event e on e.event_id = es.event_id
join committee c on c.committee_id = e.committee_id
where e.committee_id = 1
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
add a comment |
Using typical JOIN
s you can do this:
select
e.event_name,
e.start_date,
es.student_id,
s.member_type,
es.status_info
from evtstatus es
join student s on s.student_id = es.student_id
join event e on e.event_id = es.event_id
join committee c on c.committee_id = e.committee_id
where e.committee_id = 1
Using typical JOIN
s you can do this:
select
e.event_name,
e.start_date,
es.student_id,
s.member_type,
es.status_info
from evtstatus es
join student s on s.student_id = es.student_id
join event e on e.event_id = es.event_id
join committee c on c.committee_id = e.committee_id
where e.committee_id = 1
answered Jan 3 at 15:54
The ImpalerThe Impaler
11.5k41441
11.5k41441
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
add a comment |
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
@Jane . . . This seems like the right answer. How does it not work?
– Gordon Linoff
Jan 3 at 16:13
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
Guess What The Impaler? Your answer is worked for me... Thank you so much once again. I was trying this for past 1 week and now its works. :)
– Jane
Jan 4 at 13:52
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
@Jane why you've not yet accepted this answer???
– gp_sflover
Jan 12 at 13:41
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%2f54025585%2fhow-to-display-data-using-more-than-2-foreign-key-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
how is the code that gives the error?
– TDK
Jan 3 at 15:52
You can use SQL JOIN, I already ask a similar question. Check this out stackoverflow.com/questions/50179108/…
– Nawaraj
Jan 3 at 15:54