简体   繁体   中英

How to Generate This MySQL Code In Codeigniter?

This is my MySQL code. I am new to Codeigniter.

SELECT
    a.school_code,
    b.Us_News_Ranking,
    b.School_Name,
    COUNT( * ) AS LSN_APPLICATIONS,
    COUNT( a.status ) AS STATUS,
    COUNT( 
        CASE
            WHEN a.status =  'w'
            THEN a.status
        END
    ) AS accp_rate,
    COUNT( 
        CASE
            WHEN a.status =  'Intend_to_apply'
            THEN a.status
        END
    ) AS accp_rate2,
    AVG( CAST( a.Med_LSAT AS DECIMAL( 12, 2 ) ) ) AS MEd_LSAT,
    AVG( CAST( a.Med_GPA AS DECIMAL( 12, 2 ) ) ) AS MEd_GPA
FROM user_application a, lawscools b
WHERE a.school_code = b.school_code
GROUP BY school_code
LIMIT 0 , 30

You can use the query function

$this->db->query('SQL_CODE');

Well.. I guess there's another way too but why not? :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM