Jump to content
  • 0

UNION


xaero
 Share

Question

(select 
id_zv as id_zv,
orders_id as orders_id,
type_zv as type_zv,
man_id as man_id,
telephone as telephone,
date_start as date_start,
last_mod as last_mod,
prodolwit as prodolwit,
is_ok as is_ok,
local_hour as local_hour,
count as count,
record as record,
comment as comment
from
orders_status_otzvon)
UNION

(
select
'' as id_zv,
'' as orders_id,
dcontext as type_zv,
man_id as man_id,
src as telephone,
calldate as date_start,
'' as last_mod,
duration as prodolwit,
disposition as is_ok,
'' as local_hour,
'' as count,
userfield as record,
comment as comment
from
cdr)
order by date_start DESC limit 0, 20

как написать для оба таблиц одинковые условие или это не возможно?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Вообщето в документации сказано что к результату можно применить только ордер, соответственно нужно делать так:

(SELECT ... AS var1 FROM ... WHERE var1 = ...)
UNION
(SELECT ... AS var1 FROM ... WHERE var1 = ...)
ORDER BY ...

а да, вру, они только обещали это сделать ^^

Link to comment
Share on other sites

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