jaymc Posted July 9, 2009 Share Posted July 9, 2009 Im trying to do a CROSS JOIN as shown below My issue is inside the CROSS JOIN code it will not process this value t.id which is part of the initial table How can I allow the CROSS JOIN to use field values from the primary table I'm querying? SELECT t.id, t.subject, t.department, tm.date FROM fred.client_tickets t CROSS JOIN ( SELECT date FROM fred.client_ticket_messages WHERE tm.ticketID = t.id // HERE IS ISSUE, IT SAYS UNKNOWN t.id ORDER BY tm.date DESC ) tm WHERE t.clientID = '$client[id]' GROUP BY t.id ORDER BY tm.date DESC Quote Link to comment https://forums.phpfreaks.com/topic/165373-mysql-cross-join/ Share on other sites More sharing options...
Mchl Posted July 9, 2009 Share Posted July 9, 2009 SELECT t.id, t.subject, t.department, tm.date FROM fred.client_tickets t CROSS JOIN ( SELECT date, ticketID FROM fred.client_ticket_messages ORDER BY date DESC ) tm ON (tm.ticketID = t.id ) WHERE t.clientID = '$client[id]' GROUP BY t.id ORDER BY tm.date DESC Quote Link to comment https://forums.phpfreaks.com/topic/165373-mysql-cross-join/#findComment-872167 Share on other sites More sharing options...
jaymc Posted July 9, 2009 Author Share Posted July 9, 2009 Cheers worked Quote Link to comment https://forums.phpfreaks.com/topic/165373-mysql-cross-join/#findComment-872177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.