msql create view record

Because there was no record of the previous views, this time the customer company asked me to write three views, but found that I forgot how to write! So I went to Baidu and got it done in minutes. But, the individual still makes a record! I don't need to see other people's writing in the future.


#Vehicle member query view
select * from v_vehicle_member_view

drop view if EXISTS v_vehicle_member_view 

CREATE VIEW v_vehicle_member_view AS SELECT
	v.wcc_member_info MEMBER_ID,
	m.member_name MEMBER_NAME,
	m.phone_no PHONE_NO,
	DATE_FORMAT(
		m.registration_time,
		'%Y%m%d'
	) REGISTRATION_DATE,
	DATE_FORMAT(m.registration_time, '%H%i%S') REGISTRATION_TIME,
	DATE_FORMAT(v.check_date, '%Y%m%d') CHECK_DATE,
	DATE_FORMAT(v.check_date, '%H%i%S') CHECK_TIME,
	DATE_FORMAT(v.purchase_date, '%Y%m%d') PURCHASE_DATE,
	v.owner_name OWNER_NAME,
	v.vin_code VIN_CODE
FROM
	wcc_ch_vehicle v
LEFT JOIN wcc_ch_member m ON v.wcc_member_info = m.id
WHERE
	v.BINDING_STATUS = 1
AND (v. STATUS = 1 OR v. STATUS = 3)


#Vehicle unbundling view
select * from v_vehicle_unbind_view

drop view if EXISTS v_vehicle_unbind_view 

CREATE VIEW v_vehicle_unbind_view AS SELECT
	v.wcc_member_info MEMBER_ID,
	v.vin_code VIN_CODE,
	DATE_FORMAT(v.BINDING_DATE, '%Y%m%d') BINGDING_DATE,
	DATE_FORMAT(v.BINDING_DATE, '%H%i%S') BINGDING_time
FROM
	wcc_ch_vehicle v
WHERE
	v.BINDING_STATUS = 2
select * from  v_vehicle_unbind_view

#Service comment data
select * from v_service_review_view

drop view if EXISTS v_service_review_view 

CREATE VIEW v_service_review_view AS SELECT
	sv.WCC_MEMBER_INFO member_ID,
	m.member_name KICKNAME,
	m.phone_no PHONE,
	sv.VIN_CODE VIN,
	sv.settle_no DOC_NO,
	d.dealer_no SOLD_TO,
	sv.satisfaction KF01,
	sv.environment KF02,
	sv.attitude KF03,
	sv.skills KF04,
	sv.message TXT,
	DATE_FORMAT(sv.getin_time, '%Y%m%d') DATE1,
	DATE_FORMAT(sv.getin_time, '%H%i%S') TIME1,
	DATE_FORMAT(sv.review_time, '%Y%m%d') DATE2,
	DATE_FORMAT(sv.review_time, '%H%i%S') TIME2,
	DATE_FORMAT(
		sv.insert_time,
		'%Y%m%d%H%i%S'
	) CREATEDON
FROM
	wcc_ch_service_review sv
LEFT JOIN wcc_ch_member m ON sv.WCC_MEMBER_INFO = m.id
LEFT JOIN wcc_ch_dealer d ON sv.DEALER = d.id

The last message is all the content of this blog post. If you think the blog post is good, please like it. If you are interested in big data technology of other servers of the blogger or the blogger himself, please pay attention to the blogger's blog, and you are welcome to communicate with the blogger at any time.

Keywords: Database Big Data

Added by blindeddie on Sun, 08 Dec 2019 15:42:36 +0200