0

I have few db tables for practice i am converting complex sql queries to django orm queries

This is sql code i am stucked in:

"SELECT 
        hla.`id`,
        CASE 
            WHEN hla.`id` IS NULL THEN 'Not enabled'
            ELSE 'Enabled'
        END AS scv_user 
    FROM `user` u 
    INNER JOIN custo_profile cp
        ON u.`custo_profile_id` = cp.`id`
        AND cp.`is_deleted` = 0
    LEFT JOIN hl_acu_user hlacu 
        ON hlacu.`email`= cp.`email` 
    WHERE u.`user_id` = 44";

I am converting this code to django orm code, i tried using select_related but i am not able to find any solution and "scv_user" here is not a db column instead i am adding it in query runtime.

Thanks in advance if you could help me out

0 Answers0