Untitled

mail@pastecode.io avatar
unknown
mysql
a month ago
587 B
3
Indexable
Never
select `user_openai`.* 
from `user_openai` 
left join 
    (
        SELECT workspaces.id 
        FROM workspaces 
        INNER JOIN user_orders ON workspaces.created_by = user_orders.user_id
        WHERE user_orders.status = "Success"
          AND user_orders.price > 0
          AND user_orders.type = "subscription"
    ) as paying_workspaces on `user_openai`.`workspace_id` = `paying_workspaces`.`id` 
where 
    `paying_workspaces`.`id` is null 
    and `user_openai`.`root_id` is null 
    and `user_openai`.`created_at` < ? 
order by `user_openai`.`created_at` asc 
limit 100 
Leave a Comment