MYSQL LEFT JOIN not showing all the data
I am running this SQL LEFT JOIN query in PHP but it's showing one important column which is user_id
as null which is not null.
MYSQL QUERY
SELECT
a.*,
b.*,
c.*,
d.*
FROM ts_users_skills a
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
WHERE (a.`skillsTeach` = '$skill_1' OR a.`skillsTeach` = '$skill_2'
OR a.`skillsTeach` = '$skill_3')
GROUP BY a.`user_id`;
JSON output
{
"status": "success",
"nearby_teachers": [
{
"user_id": null,
"skillsTeach": "PHP",
"email": "praveenkumarkp666@gmail.com",
"country_code": "91",
"username": "praveenkum",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-02-25",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "marketing",
"email": "ashok@procusa.in",
"country_code": "91",
"username": "ashok",
"name": "Ashok the founder 2",
"birthday": "1993-11-18",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "html",
"email": "talspo@gmail.com",
"country_code": "91",
"username": "talspo",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-01-01",
"location": "Bhubaneswar"
}
]
}
Thanks in Advance.
mysql json mysqli left-join
add a comment |
I am running this SQL LEFT JOIN query in PHP but it's showing one important column which is user_id
as null which is not null.
MYSQL QUERY
SELECT
a.*,
b.*,
c.*,
d.*
FROM ts_users_skills a
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
WHERE (a.`skillsTeach` = '$skill_1' OR a.`skillsTeach` = '$skill_2'
OR a.`skillsTeach` = '$skill_3')
GROUP BY a.`user_id`;
JSON output
{
"status": "success",
"nearby_teachers": [
{
"user_id": null,
"skillsTeach": "PHP",
"email": "praveenkumarkp666@gmail.com",
"country_code": "91",
"username": "praveenkum",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-02-25",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "marketing",
"email": "ashok@procusa.in",
"country_code": "91",
"username": "ashok",
"name": "Ashok the founder 2",
"birthday": "1993-11-18",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "html",
"email": "talspo@gmail.com",
"country_code": "91",
"username": "talspo",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-01-01",
"location": "Bhubaneswar"
}
]
}
Thanks in Advance.
mysql json mysqli left-join
Learn about prepared Statements to prevent SQL injection
– Jens
Jan 2 at 14:00
Which tableuser_id
comes from? Show the code where you build the result
– Jens
Jan 2 at 14:00
Thanks for your advice on Prepared Statement. I am implementing it.
– user8893870
Jan 2 at 14:02
ts_students_log is the table where user_id is located as a Primary Key but it is present in almost every table as a Foreign key.
– user8893870
Jan 2 at 14:03
Can you please show the php code wher you build the result?
– Jens
Jan 2 at 14:12
add a comment |
I am running this SQL LEFT JOIN query in PHP but it's showing one important column which is user_id
as null which is not null.
MYSQL QUERY
SELECT
a.*,
b.*,
c.*,
d.*
FROM ts_users_skills a
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
WHERE (a.`skillsTeach` = '$skill_1' OR a.`skillsTeach` = '$skill_2'
OR a.`skillsTeach` = '$skill_3')
GROUP BY a.`user_id`;
JSON output
{
"status": "success",
"nearby_teachers": [
{
"user_id": null,
"skillsTeach": "PHP",
"email": "praveenkumarkp666@gmail.com",
"country_code": "91",
"username": "praveenkum",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-02-25",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "marketing",
"email": "ashok@procusa.in",
"country_code": "91",
"username": "ashok",
"name": "Ashok the founder 2",
"birthday": "1993-11-18",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "html",
"email": "talspo@gmail.com",
"country_code": "91",
"username": "talspo",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-01-01",
"location": "Bhubaneswar"
}
]
}
Thanks in Advance.
mysql json mysqli left-join
I am running this SQL LEFT JOIN query in PHP but it's showing one important column which is user_id
as null which is not null.
MYSQL QUERY
SELECT
a.*,
b.*,
c.*,
d.*
FROM ts_users_skills a
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
WHERE (a.`skillsTeach` = '$skill_1' OR a.`skillsTeach` = '$skill_2'
OR a.`skillsTeach` = '$skill_3')
GROUP BY a.`user_id`;
JSON output
{
"status": "success",
"nearby_teachers": [
{
"user_id": null,
"skillsTeach": "PHP",
"email": "praveenkumarkp666@gmail.com",
"country_code": "91",
"username": "praveenkum",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-02-25",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "marketing",
"email": "ashok@procusa.in",
"country_code": "91",
"username": "ashok",
"name": "Ashok the founder 2",
"birthday": "1993-11-18",
"location": "Bhubaneswar"
},
{
"user_id": null,
"skillsTeach": "html",
"email": "talspo@gmail.com",
"country_code": "91",
"username": "talspo",
"name": "Procusa Founder",
"gender": "M",
"birthday": "1997-01-01",
"location": "Bhubaneswar"
}
]
}
Thanks in Advance.
mysql json mysqli left-join
mysql json mysqli left-join
asked Jan 2 at 13:56
user8893870
Learn about prepared Statements to prevent SQL injection
– Jens
Jan 2 at 14:00
Which tableuser_id
comes from? Show the code where you build the result
– Jens
Jan 2 at 14:00
Thanks for your advice on Prepared Statement. I am implementing it.
– user8893870
Jan 2 at 14:02
ts_students_log is the table where user_id is located as a Primary Key but it is present in almost every table as a Foreign key.
– user8893870
Jan 2 at 14:03
Can you please show the php code wher you build the result?
– Jens
Jan 2 at 14:12
add a comment |
Learn about prepared Statements to prevent SQL injection
– Jens
Jan 2 at 14:00
Which tableuser_id
comes from? Show the code where you build the result
– Jens
Jan 2 at 14:00
Thanks for your advice on Prepared Statement. I am implementing it.
– user8893870
Jan 2 at 14:02
ts_students_log is the table where user_id is located as a Primary Key but it is present in almost every table as a Foreign key.
– user8893870
Jan 2 at 14:03
Can you please show the php code wher you build the result?
– Jens
Jan 2 at 14:12
Learn about prepared Statements to prevent SQL injection
– Jens
Jan 2 at 14:00
Learn about prepared Statements to prevent SQL injection
– Jens
Jan 2 at 14:00
Which table
user_id
comes from? Show the code where you build the result– Jens
Jan 2 at 14:00
Which table
user_id
comes from? Show the code where you build the result– Jens
Jan 2 at 14:00
Thanks for your advice on Prepared Statement. I am implementing it.
– user8893870
Jan 2 at 14:02
Thanks for your advice on Prepared Statement. I am implementing it.
– user8893870
Jan 2 at 14:02
ts_students_log is the table where user_id is located as a Primary Key but it is present in almost every table as a Foreign key.
– user8893870
Jan 2 at 14:03
ts_students_log is the table where user_id is located as a Primary Key but it is present in almost every table as a Foreign key.
– user8893870
Jan 2 at 14:03
Can you please show the php code wher you build the result?
– Jens
Jan 2 at 14:12
Can you please show the php code wher you build the result?
– Jens
Jan 2 at 14:12
add a comment |
2 Answers
2
active
oldest
votes
You have several columns user_id
in different tables.
In your JSON there is only one user_id
field, it is not clear from which table it is.
It is clear tho, that the data is getting lost at this point, the JSON contains a user_id
field from a dataset without a user_id
field filled.
Try using user_id
from a different table than ts_users_skills a
.
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
|
show 1 more comment
The problem with your code is that it returns several columns named user_id. Some of those values, that come from LEFT JOIN
s, may come up as NULL
.
When serializing to JSON, where keys are unique, it is likely that the « wrong » field is being chosen, resulting in a NULL
value.
To solve this, you want to list precisely the fields to retrieve from each table, instead of using *
. Of course, user_id
should come from a table that is not LEFT JOIN
ed :
SELECT
a.user_id, a.field1, a.field2
b.field11, b.field12
c.field21, c.field22, c.field23
d.field31
...
Details
You are selecting fields using the *
:
SELECT
a.*,
b.*,
c.*,
d.*
...
But your query shows that you have multiple fields named user_id
:
...
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
...
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
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%2f54007621%2fmysql-left-join-not-showing-all-the-data%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
You have several columns user_id
in different tables.
In your JSON there is only one user_id
field, it is not clear from which table it is.
It is clear tho, that the data is getting lost at this point, the JSON contains a user_id
field from a dataset without a user_id
field filled.
Try using user_id
from a different table than ts_users_skills a
.
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
|
show 1 more comment
You have several columns user_id
in different tables.
In your JSON there is only one user_id
field, it is not clear from which table it is.
It is clear tho, that the data is getting lost at this point, the JSON contains a user_id
field from a dataset without a user_id
field filled.
Try using user_id
from a different table than ts_users_skills a
.
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
|
show 1 more comment
You have several columns user_id
in different tables.
In your JSON there is only one user_id
field, it is not clear from which table it is.
It is clear tho, that the data is getting lost at this point, the JSON contains a user_id
field from a dataset without a user_id
field filled.
Try using user_id
from a different table than ts_users_skills a
.
You have several columns user_id
in different tables.
In your JSON there is only one user_id
field, it is not clear from which table it is.
It is clear tho, that the data is getting lost at this point, the JSON contains a user_id
field from a dataset without a user_id
field filled.
Try using user_id
from a different table than ts_users_skills a
.
answered Jan 2 at 14:01


DanFromGermanyDanFromGermany
19.9k74796
19.9k74796
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
|
show 1 more comment
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
i did not downvote. I just saw your answer.
– user8893870
Jan 2 at 14:05
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Try using user_id from a different table than ts_users_skills a how do you know that OP takes user_id from this table without seeing any code?
– Jens
Jan 2 at 14:09
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Yeah, I got it actually. the geo_records table was the culprit. I removed it and it worked.
– user8893870
Jan 2 at 14:24
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
Thank you @DanFromGermany for your time. I am indebted and grateful to you.
– user8893870
Jan 2 at 14:25
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
@Jens no code? He shows is SQL statement. I am programing PHP/MySQL for 18 years now, I have seen all errors, I have seen the OPs problem before and the problem and the reason is just logical - you have several fields, some can be NULL because you LEFT JOIN - result: you picked the wrong field (from the RIGHT side of the dataset).
– DanFromGermany
Jan 2 at 15:48
|
show 1 more comment
The problem with your code is that it returns several columns named user_id. Some of those values, that come from LEFT JOIN
s, may come up as NULL
.
When serializing to JSON, where keys are unique, it is likely that the « wrong » field is being chosen, resulting in a NULL
value.
To solve this, you want to list precisely the fields to retrieve from each table, instead of using *
. Of course, user_id
should come from a table that is not LEFT JOIN
ed :
SELECT
a.user_id, a.field1, a.field2
b.field11, b.field12
c.field21, c.field22, c.field23
d.field31
...
Details
You are selecting fields using the *
:
SELECT
a.*,
b.*,
c.*,
d.*
...
But your query shows that you have multiple fields named user_id
:
...
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
...
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
add a comment |
The problem with your code is that it returns several columns named user_id. Some of those values, that come from LEFT JOIN
s, may come up as NULL
.
When serializing to JSON, where keys are unique, it is likely that the « wrong » field is being chosen, resulting in a NULL
value.
To solve this, you want to list precisely the fields to retrieve from each table, instead of using *
. Of course, user_id
should come from a table that is not LEFT JOIN
ed :
SELECT
a.user_id, a.field1, a.field2
b.field11, b.field12
c.field21, c.field22, c.field23
d.field31
...
Details
You are selecting fields using the *
:
SELECT
a.*,
b.*,
c.*,
d.*
...
But your query shows that you have multiple fields named user_id
:
...
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
...
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
add a comment |
The problem with your code is that it returns several columns named user_id. Some of those values, that come from LEFT JOIN
s, may come up as NULL
.
When serializing to JSON, where keys are unique, it is likely that the « wrong » field is being chosen, resulting in a NULL
value.
To solve this, you want to list precisely the fields to retrieve from each table, instead of using *
. Of course, user_id
should come from a table that is not LEFT JOIN
ed :
SELECT
a.user_id, a.field1, a.field2
b.field11, b.field12
c.field21, c.field22, c.field23
d.field31
...
Details
You are selecting fields using the *
:
SELECT
a.*,
b.*,
c.*,
d.*
...
But your query shows that you have multiple fields named user_id
:
...
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
...
The problem with your code is that it returns several columns named user_id. Some of those values, that come from LEFT JOIN
s, may come up as NULL
.
When serializing to JSON, where keys are unique, it is likely that the « wrong » field is being chosen, resulting in a NULL
value.
To solve this, you want to list precisely the fields to retrieve from each table, instead of using *
. Of course, user_id
should come from a table that is not LEFT JOIN
ed :
SELECT
a.user_id, a.field1, a.field2
b.field11, b.field12
c.field21, c.field22, c.field23
d.field31
...
Details
You are selecting fields using the *
:
SELECT
a.*,
b.*,
c.*,
d.*
...
But your query shows that you have multiple fields named user_id
:
...
LEFT JOIN ts_students_log b
ON a.`user_id` = b.`user_id`
LEFT JOIN ts_students_info c
ON a.`user_id` = c.`user_id`
LEFT JOIN `geo_records` d
ON a.`user_id` = d.`user_id`
...
edited Jan 2 at 14:11
answered Jan 2 at 14:06


GMBGMB
18.8k31028
18.8k31028
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
add a comment |
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
yeah I have multiple user_id. let me try.
– user8893870
Jan 2 at 14:10
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
This is practically the same as my answer but your explanation is way better understandable
– DanFromGermany
Jan 2 at 15:50
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%2f54007621%2fmysql-left-join-not-showing-all-the-data%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
Learn about prepared Statements to prevent SQL injection
– Jens
Jan 2 at 14:00
Which table
user_id
comes from? Show the code where you build the result– Jens
Jan 2 at 14:00
Thanks for your advice on Prepared Statement. I am implementing it.
– user8893870
Jan 2 at 14:02
ts_students_log is the table where user_id is located as a Primary Key but it is present in almost every table as a Foreign key.
– user8893870
Jan 2 at 14:03
Can you please show the php code wher you build the result?
– Jens
Jan 2 at 14:12