Evening all,
I'm having a problem with a query I've written.. not sure what the problem is as I get this error..
I've underlined the problematic areas...
If I take out the problematic where clause replyid does return a value, so I guess it's something todo with the subquery being unable to access replyid..
Any ideas would be appreciated...
I'm having a problem with a query I've written.. not sure what the problem is as I get this error..
#1054 - Unknown column 'replyid' in 'where clause'
I've underlined the problematic areas...
Code:
SELECT `helpdesk_tickets`.`id` , `helpdesk_tickets`.`status` , `helpdesk_tickets`.`subject` , `users`.`first_name` , `users`.`last_name` , `users`.`id` AS `uid` ,
(SELECT `helpdesk_tickets_replies`.`date`
FROM `helpdesk_tickets_replies`
WHERE `helpdesk_tickets_replies`.`tid` = `helpdesk_tickets`.`id`
ORDER BY `helpdesk_tickets_replies`.`date` DESC
LIMIT 1
) AS `replydate` ,
[U](SELECT `helpdesk_tickets_replies`.`id`
FROM `helpdesk_tickets_replies`
WHERE `helpdesk_tickets_replies`.`tid` = `helpdesk_tickets`.`id`
ORDER BY `helpdesk_tickets_replies`.`date` DESC
LIMIT 1
) AS `replyid`[/U]
FROM `helpdesk_tickets`
INNER JOIN `users` ON `helpdesk_tickets`.`uid` = `users`.`id`
WHERE (
`helpdesk_tickets`.`status` = '0'
OR `helpdesk_tickets`.`status` = '2'
)
AND NOT
EXISTS (
SELECT `helpdesk_noti`.`id`
FROM `helpdesk_noti`
WHERE `helpdesk_noti`.`type` = 't'
AND `helpdesk_noti`.`uid` = `users`.`id`
[U]AND `helpdesk_noti`.`nid` = `replyid`[/U]
)
ORDER BY `replydate` ASC
If I take out the problematic where clause replyid does return a value, so I guess it's something todo with the subquery being unable to access replyid..
Any ideas would be appreciated...