Answer the question
In order to leave comments, you need to log in
How to select from the resulting table?
How to make a selection from the resulting table? I try this way and then do where , but nothing comes out, although the subquery itself returns n-number of rows
SELECT result_table.* FROM (
SELECT barmen_companies_objects.`company`,
`barmen_comments`.*,
`barmen_users_objects`.`name`,
`barmen_users_objects`.`surname`,
barmen_orders.user_full_name,
barmen_users_companies.company_id = barmen_comments.company_id as company_equality
From `barmen_comments`
LEFT JOIN `barmen_users_objects` ON `barmen_comments`.`user_id`=`barmen_users_objects`.`user_id`
LEFT JOIN barmen_users_companies ON barmen_comments.user_id = barmen_users_companies.user_id
LEFT JOIN barmen_companies_objects ON barmen_companies_objects.company_id = barmen_users_companies.company_id
LEFT JOIN `barmen_orders` ON `barmen_comments`.order_id = barmen_orders.order_id
where `barmen_comments`.`product_id`={$productId}
and `barmen_comments`.`status_read` !=3
and `barmen_comments`.`productOrCompany`=0
and `barmen_comments`.user_id is not null
order by `barmen_comments`.`date_created` desc, `barmen_comments`.`comments_id`) as result_table
Answer the question
In order to leave comments, you need to log in
Maybe you just don't get errors?
I don’t know how in MySQL, but in MS SQL, in this case, order by must be taken out or TOP must be used inside.
try sorting.
order by result_table.`date_created` desc, result_table.`comments_id`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question