S
S
SaimonPhoenix2015-10-05 18:57:43
Database
SaimonPhoenix, 2015-10-05 18:57:43

How to fetch data from table1 or from table2?

Hello!
There were difficulties with data sampling.
Given:
table Orders; (PK: OrderId) - Orders
table Legal entities (PK: FirmID, FK:OrderId) - Firms;
table Individuals (PK:PersonID, FK:OrderID) - Persons;
Jur. Persons
FirmsID;
ordersID;
companyname;
Individual
PersonsID;
ordersID;
FLPName;(client name)
Orders
OrdersID
ContractDate;
comment;
The orders table has a primary key Orders.OrderId which can be used to link legal tables. faces and physical faces. How to merge into one column Jur. individuals and physical persons(customer column)? That is, the result of the request should be one value - the client (legal entity or individual).

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Kovalsky, 2015-10-05
@SaimonPhoenix

I can suggest you join everything, and use a function like coalesce in mssql in the list of output columns. you get something like coalesce(jurname,fizname,"') as clientname

S
Sanan Yuzb, 2015-10-05
@Sanan07

ViaUNION

M
mik_os, 2012-03-01
@mik_os

include renders the template with the data that it has at a particular point in time, returns a ready-made rendered text. Your block is redefined after the templates are rendered.

S
simplecode, 2012-03-01
@simplecode

Got it, thanks! We'll have to merge everything from "index_*.html" to "index.html".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question