3 TABLES IN 1 VIEW
3 TABLES IN 1 VIEW
antoniocib
Posts: 277Questions: 62Answers: 1
Hi Guys i hope than you can help me!
I' ve 3 tables SQL but i want group this 3 table in a view
this is the pattern of tables is the same:
Table 1/2/3:
i want to make this result:
This only if the "IND" field is equal to 1, otherwise it must not add them in the view
CREATE VIEW bologna AS
SELECT
scrivania1.ddt,scrivania2.ddt,scrivania3.ddt,
scrivania1.cliente,scrivania2.cliente,scrivania3.cliente,
scrivania1.carico,scrivania2.carico,scrivania3.carico,
scrivania1.destinazione,scrivania2.destinazione,scrivania3.destinazione,
scrivania1.pr,scrivania2.pr,scrivania3.pr,
scrivania1.scarico,scrivania2.scarico,scrivania3.scarico,
scrivania1.scarico_m,scrivania2.scarico_m,scrivania3.scarico_m,
scrivania1.data_di_scarico,scrivania2.data_di_scarico,scrivania3.data_di_scarico,
scrivania1.ind,scrivania2.ind,scrivania3.ind
FROM scrivania1,scrivania2,scrivania3
WHERE scrivania1.ind, scrivania2.ind, scrivania3.ind = "1"
Thanks all.
This discussion has been closed.
Answers
Would you want that table to also be editable with Editor? Or just a read-only DataTable?
Colin
If all of your 3 tables' definitions are identical I would use UNION ALL. This requires aliasing all of the columns to have identical names across all of the 3 tables. You'll find lots on this on Stack Overflow.
But you would still need to answer @colin s question, I guess.
@colin and @rf1234 i want than that table is editable, i just use UNION ALL but in this way i cant edit the table
Yes, unfortunately our Editor server-side libraries do not support direct UNION access. If your database allows INSERT/UPDATE/DELETE to be performed on your VIEW (I think some do, some don't - and even those that do probably have limitations based on what the VIEW is doing) then it would work with the libraries as is. But if not, unfortunately you'd need to write your own server-side code for the insert, update and delete actions.
If you need to do that, the client / server data interchange for Editor is available here and I'm happy to answer any questions you have about it.
Allan
Um, I don't even know how to start doing all this I thought that with Editor in a very easy way I could do it, being that not so programming I have to find another solution, thanks @allan for the arrangement.