MySQL 练习多表联合查询

SELECT  U.USER AS 用户ID, U.NAME AS 昵称, C.CONTENT AS 内容, C.TIME AS 时间 ,LM.CODE AS 编号
FROM (
  SELECT CONTENT, USER, ID, TIME FROM message WHERE 
    `TIME` > '2020-01-01' AND `TIME` <= '2020-01-31' 
     AND ( 
		 CONTENT LIKE '%QQ%' 
		 or CONTENT LIKE '%+V%' 
		 or CONTENT REGEXP '(壹|贰|叁|肆|伍|陆|柒|捌|玖|零|一|二|三|四|五|六|七|八|九|0|1|2|3|4|5|6|7|8|9){8,}'  
		 )
) C LEFT JOIN  user U on C.ID = U.ID 
LEFT JOIN info LI on C.ID = LI.ID
LEFT JOIN main LM on Li.ID = LM.ID order by C.TIME
;

涉及到正则,已查询到结果与另外3张表联查

posted @ 2020-05-23 11:34  klvchen  阅读(490)  评论(0编辑  收藏  举报