Mysql利用别名多表查询

  • A+
所属分类:Mysql

mysql查询时,可以对表和列增加别名,DISTINCT表示去重,为两个表增加t和d别名,如果多库查询记得写库名。

示例:

SELECT DISTINCT

t.cc_user_id,

d.staff_name

FROM

vg_notice_cclist t,

vancloud_user.vg_user_detail d

WHERE

t.notice_id = '847178984029425664'

AND t.cc_user_id = d.user_id

AND d.state = 'active'

YaLei

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: