MySql教程

mysql 实例

本文主要是介绍mysql 实例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
SELECT
    a.*, FROM_UNIXTIME(
        a.createTime,
        '%Y-%m-%d %H:%i:%s'
    ) AS createTimeStr,
    FROM_UNIXTIME(
        a.updateTime,
        '%Y-%m-%d %H:%i:%s'
    ) AS updateTimeStr,
    b.`orgName` AS deptName,
    c.`realUserName` AS userName,
    d.`realUserName` AS updateName
FROM
    (
        SELECT
            v.*, (
                SELECT
                    COUNT(*)
                FROM
                    wx_article_info w
                WHERE
                    w.wxCode = v.wxCode
            ) AS articleCount
        FROM
            wx_base_info v
        LEFT JOIN sys_users su ON v.`userId` = su.`userId`
        WHERE
            1 = 1
        AND v.cityCode LIKE CONCAT('34', '%')
        AND v.deptCode LIKE concat('34', '%')
    ) a
LEFT JOIN sys_org b ON a.`deptCode` = b.`orgCode`
LEFT JOIN sys_users c ON a.`userId` = c.`userId`
LEFT JOIN sys_users d ON a.`updateId` = d.`userId`
WHERE
    1 = 1
ORDER BY
    a.updateTime DESC,
    a.articleCount DESC

 

这篇关于mysql 实例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!