MySQL column ALIAS in WHERE clause
In this below query I have two tables, search_result
and login_details
.
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0;
NOTE: reg_id is a column in
login_details
and registration is a column insearch_result
By executing above query I'm getting fullname and the last login time of all the users in search_result
table.
Now my requirement is to fetch all the users along with the last login time who all are not logged in for last 180 days from today. When I add a WHERE
condition like login_time > '2018-05-22 18:09:00'
, it shows error Unknown column login_time blah blah.....
Query:
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0 AND login_time > '2018-05-22 18:09:00';
Please help me to find exact query. Answers will be appreciated. Thanks
mysql sql where-clause
add a comment |
In this below query I have two tables, search_result
and login_details
.
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0;
NOTE: reg_id is a column in
login_details
and registration is a column insearch_result
By executing above query I'm getting fullname and the last login time of all the users in search_result
table.
Now my requirement is to fetch all the users along with the last login time who all are not logged in for last 180 days from today. When I add a WHERE
condition like login_time > '2018-05-22 18:09:00'
, it shows error Unknown column login_time blah blah.....
Query:
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0 AND login_time > '2018-05-22 18:09:00';
Please help me to find exact query. Answers will be appreciated. Thanks
mysql sql where-clause
Possible duplicate of Unknown column issue with mysql alias
– Nico Haase
Nov 22 '18 at 14:23
@NicoHaase Yes I know.. But I'm not getting with it.
– Shihas
Nov 22 '18 at 14:24
Can't you use aJOIN
?
– Cid
Nov 22 '18 at 14:25
What do you mean by that? Both the linked answers and the one here by Maxim tell you very clearly that you just cannot use the aliased column name in theWHERE
clause
– Nico Haase
Nov 22 '18 at 14:25
reg_id=registration
- in this which column belongs to which table ?
– Madhur Bhaiya
Nov 22 '18 at 14:29
add a comment |
In this below query I have two tables, search_result
and login_details
.
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0;
NOTE: reg_id is a column in
login_details
and registration is a column insearch_result
By executing above query I'm getting fullname and the last login time of all the users in search_result
table.
Now my requirement is to fetch all the users along with the last login time who all are not logged in for last 180 days from today. When I add a WHERE
condition like login_time > '2018-05-22 18:09:00'
, it shows error Unknown column login_time blah blah.....
Query:
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0 AND login_time > '2018-05-22 18:09:00';
Please help me to find exact query. Answers will be appreciated. Thanks
mysql sql where-clause
In this below query I have two tables, search_result
and login_details
.
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0;
NOTE: reg_id is a column in
login_details
and registration is a column insearch_result
By executing above query I'm getting fullname and the last login time of all the users in search_result
table.
Now my requirement is to fetch all the users along with the last login time who all are not logged in for last 180 days from today. When I add a WHERE
condition like login_time > '2018-05-22 18:09:00'
, it shows error Unknown column login_time blah blah.....
Query:
SELECT fullname,
(SELECT MAX(login_time) FROM login_details WHERE reg_id=registration) as login_time
FROM search_result WHERE hire_work=0 AND login_time > '2018-05-22 18:09:00';
Please help me to find exact query. Answers will be appreciated. Thanks
mysql sql where-clause
mysql sql where-clause
edited Nov 22 '18 at 14:21
Shihas
asked Nov 22 '18 at 14:13
ShihasShihas
634625
634625
Possible duplicate of Unknown column issue with mysql alias
– Nico Haase
Nov 22 '18 at 14:23
@NicoHaase Yes I know.. But I'm not getting with it.
– Shihas
Nov 22 '18 at 14:24
Can't you use aJOIN
?
– Cid
Nov 22 '18 at 14:25
What do you mean by that? Both the linked answers and the one here by Maxim tell you very clearly that you just cannot use the aliased column name in theWHERE
clause
– Nico Haase
Nov 22 '18 at 14:25
reg_id=registration
- in this which column belongs to which table ?
– Madhur Bhaiya
Nov 22 '18 at 14:29
add a comment |
Possible duplicate of Unknown column issue with mysql alias
– Nico Haase
Nov 22 '18 at 14:23
@NicoHaase Yes I know.. But I'm not getting with it.
– Shihas
Nov 22 '18 at 14:24
Can't you use aJOIN
?
– Cid
Nov 22 '18 at 14:25
What do you mean by that? Both the linked answers and the one here by Maxim tell you very clearly that you just cannot use the aliased column name in theWHERE
clause
– Nico Haase
Nov 22 '18 at 14:25
reg_id=registration
- in this which column belongs to which table ?
– Madhur Bhaiya
Nov 22 '18 at 14:29
Possible duplicate of Unknown column issue with mysql alias
– Nico Haase
Nov 22 '18 at 14:23
Possible duplicate of Unknown column issue with mysql alias
– Nico Haase
Nov 22 '18 at 14:23
@NicoHaase Yes I know.. But I'm not getting with it.
– Shihas
Nov 22 '18 at 14:24
@NicoHaase Yes I know.. But I'm not getting with it.
– Shihas
Nov 22 '18 at 14:24
Can't you use a
JOIN
?– Cid
Nov 22 '18 at 14:25
Can't you use a
JOIN
?– Cid
Nov 22 '18 at 14:25
What do you mean by that? Both the linked answers and the one here by Maxim tell you very clearly that you just cannot use the aliased column name in the
WHERE
clause– Nico Haase
Nov 22 '18 at 14:25
What do you mean by that? Both the linked answers and the one here by Maxim tell you very clearly that you just cannot use the aliased column name in the
WHERE
clause– Nico Haase
Nov 22 '18 at 14:25
reg_id=registration
- in this which column belongs to which table ?– Madhur Bhaiya
Nov 22 '18 at 14:29
reg_id=registration
- in this which column belongs to which table ?– Madhur Bhaiya
Nov 22 '18 at 14:29
add a comment |
2 Answers
2
active
oldest
votes
Your query doesn't work, because WHERE statement executes before SELECT statement.
You should use HAVING statement to filtering of calculating fields. For example:
SELECT fullname,
(SELECT MAX(login_time)
FROM login_details
WHERE reg_id=registration) AS login_time
FROM search_result
WHERE hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
Also, subqueries aren't good practice. You can rewrite this query with JOIN
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
And.. Instead of a constant date, you can use the following expression: NOW() - INTERVAL 180 DAY
. For example:
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < NOW() - INTERVAL 180 DAY
This will fail in newer versions of MySQL withonly_full_group_by
mode.having
withoutgroup by
is indeterministic, and no aggregation is used either.
– Madhur Bhaiya
Nov 22 '18 at 14:24
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
1
I believe it should belogin_time <
.
– Salman A
Nov 22 '18 at 14:31
add a comment |
The reason why you cannot use aliases (that you assigning in SELECT part) is that this part is executed after WHERE part. So these aliases are not available when SQL server executes WHERE part.
I would not use queries with HAVING without a reason as they are usually more resource expensive for SQL server.
As you are after users who does NOT log in after specified datetime, you do not need to find MAX login time at all and simple left join could be enough:
SELECT
sr.fullname
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
If you still need the last login time for such users (that would be before the datetime you specified), you can add another subquery (as in your original query) something like this:
SELECT
sr.fullname
, (
SELECT
MAX(login_details.login_time)
FROM
login_details
WHERE
login_details.reg_id = sr.registration
) AS last_login_time
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
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%2f53432870%2fmysql-column-alias-in-where-clause%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
Your query doesn't work, because WHERE statement executes before SELECT statement.
You should use HAVING statement to filtering of calculating fields. For example:
SELECT fullname,
(SELECT MAX(login_time)
FROM login_details
WHERE reg_id=registration) AS login_time
FROM search_result
WHERE hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
Also, subqueries aren't good practice. You can rewrite this query with JOIN
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
And.. Instead of a constant date, you can use the following expression: NOW() - INTERVAL 180 DAY
. For example:
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < NOW() - INTERVAL 180 DAY
This will fail in newer versions of MySQL withonly_full_group_by
mode.having
withoutgroup by
is indeterministic, and no aggregation is used either.
– Madhur Bhaiya
Nov 22 '18 at 14:24
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
1
I believe it should belogin_time <
.
– Salman A
Nov 22 '18 at 14:31
add a comment |
Your query doesn't work, because WHERE statement executes before SELECT statement.
You should use HAVING statement to filtering of calculating fields. For example:
SELECT fullname,
(SELECT MAX(login_time)
FROM login_details
WHERE reg_id=registration) AS login_time
FROM search_result
WHERE hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
Also, subqueries aren't good practice. You can rewrite this query with JOIN
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
And.. Instead of a constant date, you can use the following expression: NOW() - INTERVAL 180 DAY
. For example:
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < NOW() - INTERVAL 180 DAY
This will fail in newer versions of MySQL withonly_full_group_by
mode.having
withoutgroup by
is indeterministic, and no aggregation is used either.
– Madhur Bhaiya
Nov 22 '18 at 14:24
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
1
I believe it should belogin_time <
.
– Salman A
Nov 22 '18 at 14:31
add a comment |
Your query doesn't work, because WHERE statement executes before SELECT statement.
You should use HAVING statement to filtering of calculating fields. For example:
SELECT fullname,
(SELECT MAX(login_time)
FROM login_details
WHERE reg_id=registration) AS login_time
FROM search_result
WHERE hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
Also, subqueries aren't good practice. You can rewrite this query with JOIN
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
And.. Instead of a constant date, you can use the following expression: NOW() - INTERVAL 180 DAY
. For example:
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < NOW() - INTERVAL 180 DAY
Your query doesn't work, because WHERE statement executes before SELECT statement.
You should use HAVING statement to filtering of calculating fields. For example:
SELECT fullname,
(SELECT MAX(login_time)
FROM login_details
WHERE reg_id=registration) AS login_time
FROM search_result
WHERE hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
Also, subqueries aren't good practice. You can rewrite this query with JOIN
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < '2018-05-22 18:09:00'
And.. Instead of a constant date, you can use the following expression: NOW() - INTERVAL 180 DAY
. For example:
SELECT search_result.fullname,
MAX(login_details.login_time) AS login_time
FROM search_result
JOIN login_details ON login_details.reg_id=search_result.registration
WHERE search_result.hire_work=0
GROUP BY fullname
HAVING login_time < NOW() - INTERVAL 180 DAY
edited Nov 22 '18 at 14:37
answered Nov 22 '18 at 14:19
Maxim FedorovMaxim Fedorov
3,261420
3,261420
This will fail in newer versions of MySQL withonly_full_group_by
mode.having
withoutgroup by
is indeterministic, and no aggregation is used either.
– Madhur Bhaiya
Nov 22 '18 at 14:24
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
1
I believe it should belogin_time <
.
– Salman A
Nov 22 '18 at 14:31
add a comment |
This will fail in newer versions of MySQL withonly_full_group_by
mode.having
withoutgroup by
is indeterministic, and no aggregation is used either.
– Madhur Bhaiya
Nov 22 '18 at 14:24
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
1
I believe it should belogin_time <
.
– Salman A
Nov 22 '18 at 14:31
This will fail in newer versions of MySQL with
only_full_group_by
mode. having
without group by
is indeterministic, and no aggregation is used either.– Madhur Bhaiya
Nov 22 '18 at 14:24
This will fail in newer versions of MySQL with
only_full_group_by
mode. having
without group by
is indeterministic, and no aggregation is used either.– Madhur Bhaiya
Nov 22 '18 at 14:24
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
Thanks for the comment! I made a mistake. I fix it.
– Maxim Fedorov
Nov 22 '18 at 14:29
1
1
I believe it should be
login_time <
.– Salman A
Nov 22 '18 at 14:31
I believe it should be
login_time <
.– Salman A
Nov 22 '18 at 14:31
add a comment |
The reason why you cannot use aliases (that you assigning in SELECT part) is that this part is executed after WHERE part. So these aliases are not available when SQL server executes WHERE part.
I would not use queries with HAVING without a reason as they are usually more resource expensive for SQL server.
As you are after users who does NOT log in after specified datetime, you do not need to find MAX login time at all and simple left join could be enough:
SELECT
sr.fullname
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
If you still need the last login time for such users (that would be before the datetime you specified), you can add another subquery (as in your original query) something like this:
SELECT
sr.fullname
, (
SELECT
MAX(login_details.login_time)
FROM
login_details
WHERE
login_details.reg_id = sr.registration
) AS last_login_time
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
add a comment |
The reason why you cannot use aliases (that you assigning in SELECT part) is that this part is executed after WHERE part. So these aliases are not available when SQL server executes WHERE part.
I would not use queries with HAVING without a reason as they are usually more resource expensive for SQL server.
As you are after users who does NOT log in after specified datetime, you do not need to find MAX login time at all and simple left join could be enough:
SELECT
sr.fullname
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
If you still need the last login time for such users (that would be before the datetime you specified), you can add another subquery (as in your original query) something like this:
SELECT
sr.fullname
, (
SELECT
MAX(login_details.login_time)
FROM
login_details
WHERE
login_details.reg_id = sr.registration
) AS last_login_time
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
add a comment |
The reason why you cannot use aliases (that you assigning in SELECT part) is that this part is executed after WHERE part. So these aliases are not available when SQL server executes WHERE part.
I would not use queries with HAVING without a reason as they are usually more resource expensive for SQL server.
As you are after users who does NOT log in after specified datetime, you do not need to find MAX login time at all and simple left join could be enough:
SELECT
sr.fullname
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
If you still need the last login time for such users (that would be before the datetime you specified), you can add another subquery (as in your original query) something like this:
SELECT
sr.fullname
, (
SELECT
MAX(login_details.login_time)
FROM
login_details
WHERE
login_details.reg_id = sr.registration
) AS last_login_time
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
The reason why you cannot use aliases (that you assigning in SELECT part) is that this part is executed after WHERE part. So these aliases are not available when SQL server executes WHERE part.
I would not use queries with HAVING without a reason as they are usually more resource expensive for SQL server.
As you are after users who does NOT log in after specified datetime, you do not need to find MAX login time at all and simple left join could be enough:
SELECT
sr.fullname
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
If you still need the last login time for such users (that would be before the datetime you specified), you can add another subquery (as in your original query) something like this:
SELECT
sr.fullname
, (
SELECT
MAX(login_details.login_time)
FROM
login_details
WHERE
login_details.reg_id = sr.registration
) AS last_login_time
FROM
search_result AS sr
LEFT JOIN login_details AS ld ON (
ld.reg_id = sr.registration
AND ld.login_time > '2018-05-22 18:09:00'
)
WHERE
sr.hire_work = 0
AND ld.login_time IS NULL
;
answered Nov 23 '18 at 1:09
fifonikfifonik
44429
44429
add a comment |
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%2f53432870%2fmysql-column-alias-in-where-clause%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
Possible duplicate of Unknown column issue with mysql alias
– Nico Haase
Nov 22 '18 at 14:23
@NicoHaase Yes I know.. But I'm not getting with it.
– Shihas
Nov 22 '18 at 14:24
Can't you use a
JOIN
?– Cid
Nov 22 '18 at 14:25
What do you mean by that? Both the linked answers and the one here by Maxim tell you very clearly that you just cannot use the aliased column name in the
WHERE
clause– Nico Haase
Nov 22 '18 at 14:25
reg_id=registration
- in this which column belongs to which table ?– Madhur Bhaiya
Nov 22 '18 at 14:29