Jump to content
  • 0

create view


xaero
 Share

Question

Вот у меня есть такой query и я созадю view чтобы было удобно работать с условиями иначе каждому отдельный условия написать надо

всё работает но с скоростью беда !!!!

ест ли какой нибуд способ чтобы он работал быстро

create or replace view log_tables as

(select
cd.id_cd as id,
cd.man_id as man_id,
concat(man.username, ' ',man.lastname) as actor_name,
cd.calldate as date_start,
DATE_ADD(cd.calldate, INTERVAL cd.duration SECOND) as date_finish,
29 as type,
'view' as action,
cd.comment as comment
from
cdr as cd
left join managers as man on (cd.man_id = man.man_id)
)

union

(select
otz.id_zv as id,
otz.man_id as man_id,
concat(man.username, ' ',man.lastname) as actor_name,
otz.date_start as date_start,
DATE_ADD(otz.date_start, INTERVAL otz.prodolwit SECOND) as date_finish,
28 as type,
'view' as action,
otz.comment as comment
from
orders_status_otzvon as otz
left join managers as man on (otz.man_id = man.man_id)
)

union

(select
ohs.id as id,
ohs.manager_id as man_id,
concat(man.username, ' ',man.lastname) as actor_name,
ohs.date_open as date_start,
ohs.date_finish as date_finish,
3 as type,
'view' as action,
ohs.comments as comment
from
orders_status_history_work as ohs
left join managers as man on (ohs.manager_id = man.man_id)
)

union

(select
log.id as id,
log.actor_id as man_id,
concat(man.username, ' ',man.lastname) as actor_name,
log.date as date_start,
now() as date_finish,
0 as type,
'view' as action,
log.text as comment
from
log
left join managers as man on (log.actor_id = man.man_id)
)

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy