About View In Sql

How Can I Make A View For My Table Using Sql
And Select Fields From This View From Another Query
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


If you are talking about MS SQL then:
1. Use CREATE VIEW statement

with ADOQuery1 do begin
  SQL.Add('SELECT Field1, Field2 FROM Table1');

2. Use the already created view as regular table

with ADOQuery2 do begin
  SQL.Add('SELECT * FROM MyView');
  // do something here

Regards, Geo
waelolabiAuthor Commented:
My Dear
I Am Using A Paradox Tabels
So I Am Using BDE Query In My Project
And This Code Did Not Work On BDE Query
And I Have The Following Error Message : "Cabapility Not Support"

What Is The Solution
How Can I Make A View In This Case

And Thanks For Your Help
Would you explain what you understand as 'view' in paradox? As far as I know there is no such thing. I said that my code above is for MSSQL server.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

waelolabiAuthor Commented:
Hi geobul
Thanks For Your Help
Your Code Is Perfect And Working Very Well In Acsess Database
(Ado Components in Delphi)
But As I Said:
I Am Using Paradox7 Database (BDE Components In Delphi)
And Your Code Is Not Working On This Database

Hope You Understand Me
Waiting Your Reply Please
Again: Would you explain what you understand as 'view' in paradox? As far as I know there is no such thing.
A possible solution could be:

1. using CREATE TABLE statement create a new empty table with the desired structure

  custno NUMERIC(10,2),
  company CHAR(20)

2. using INSERT INTO statement with SELECT inside fill that table:

(custno, company)
SELECT custno, company
FROM "customer.db" WHERE custno > 100

3. use MyView as a regular table in another query

4. when you don't need it anymore execute
DROP TABLE "MyView.db"

Regards, Geo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
waelolabiAuthor Commented:
Hi geobul
I Will Try You Final Soulution I Hope It Is Ok

About View In Paradox I Meant Using Sql (Creat View Command) on Paradox7 Database Using BDE Component In Delphi6 (Tquery)
Rather Than Ado Component (Tadoquery)

There is no difference whether you'll use TQuery or TADOQuery. The problem is if Paradox supports CREATE VIEW command. I think it doesn't. That's why I proposed creating a new table instead.

Regards, Geo
waelolabiAuthor Commented:
Please What Is Th Name Of The Sql Language That We Use In Delphi
Is It (MsSql, Sql Server ........... etc)
If you have MSSQL server then you'll use MS Transact SQL, if you connect to Oracle then you'll use Oracle's SQL etc. Delphi passes SQL statements to the SQL server you are connected to.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.