Questions tagged [sql-view]

A database view is a stored query. Its output automatically updates as underlying table data changes.

A database view does not store data as tables (temporary or otherwise) do; rather, it is a saved query that can be recalled and reused. Its output automatically updates as underlying table data changes.

Reference

990 questions
21
votes
2 answers

Data from two tables into one view

Is it possible to grab data from two tables (that have the same fields) into one view. Basically, so the view sees the data as if it was one table.
Marcin
  • 1,266
  • 3
  • 15
  • 31
20
votes
1 answer

How can users prove a specific account has access to BigQuery? (AEAD encryption and authorized views)

I'm running an event where multiple people need to access BigQuery, and I want them to send me a proof that they have access: I want to collect email addresses of participants that can access BigQuery. I want proof that they have used…
Felipe Hoffa
  • 54,922
  • 16
  • 151
  • 325
20
votes
3 answers

Wordpress users and usermeta - joining multiple rows in one table to one row in another table

I want to create a view from both the wp_users and wp_usermeta tables so that I can query rows in the view from an external application. Basic auth details are stored in wp_users (e.g. username, password, email, id) and other fields are stored in…
frumbert
  • 2,323
  • 5
  • 30
  • 61
17
votes
4 answers

SQL Updatable View with joined tables

I have a view that looks similar to this, SELECT dbo.Staff.StaffId, dbo.Staff.StaffName, dbo.StaffPreferences.filter_type FROM dbo.Staff LEFT OUTER JOIN dbo.StaffPreferences ON dbo.Staff.StaffId = dbo.StaffPreferences.StaffId I'm trying…
Red Taz
  • 4,159
  • 4
  • 38
  • 60
16
votes
3 answers

Prepend table name to each column in a result set in SQL? (Postgres specifically)

How can I get the label of each column in a result set to prepend the name if its table? I want this to happen for queries on single tables as well as joins. Example: SELECT first_name, last_name FROM person; I want the results to be: |…
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
15
votes
5 answers

MYSQL UPDATE with IN and Subquery

Hi i have tables like this : table entry : id | total_comments _____________________ 1 | 0 2 | 0 3 | 0 4 | 0 table comments : id | eid | comment _____________________ 1 | 1 | comment sdfd 2 | 1 | testing…
Johal
  • 597
  • 1
  • 7
  • 23
14
votes
1 answer

How much space does a view take up in Microsoft SQL Server

I have a very large table in SQL Server 2008. It has lots of fields which are only useful to a certain segment of users, some of the fields some users shouldn't be able to see. The table is huge so I wanted to create some simple views for each user…
Great Turtle
  • 3,315
  • 7
  • 32
  • 36
14
votes
2 answers

Convert nvarchar to int in order to join SQL tables in a view

I want to create a view which will display the info from two tables joined by different type fields. The one field is nvarchar and the other one is int. I know i need to convert one type in the other but don't know how to do it. Any help would be…
Charalampos Afionis
  • 193
  • 1
  • 1
  • 11
13
votes
2 answers

View or stored procedure for complex queries?

I have a somewhat complex query with multiple (nested) sub-queries, which I want to make available for the applications developers. The query is generic and generates a view with computed values over a collection of data sets, and the developer is…
Guss
  • 30,470
  • 17
  • 104
  • 128
13
votes
1 answer

How to map a database view without a primary key when using JPA

I have views in a SQL database with no obvious primary key (composite or otherwise) I would like to access them through JPA I've read that I should be able to treat views in JPA like I treat tables (using the @Table annotation etc.). However…
Andy N
  • 1,238
  • 1
  • 12
  • 30
13
votes
3 answers

Why do SQL Server Views needs to be refreshed every once in a while

Why do I have to write 'refresh view' scripts, and execute them every time I add or edit some fields to a view? SQL Server understands that it needs to refresh the view when editing it in the fancy view-edit windows in Management Studio, so why…
Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120
13
votes
2 answers

How to create a not null column in a view

Given a table like: CREATE TABLE "MyTable" ( "MyColumn" NUMBER NOT NULL ); I want to create a view like: CREATE VIEW "MyView" AS SELECT CAST("MyColumn" AS BINARY_DOUBLE) AS "MyColumn" FROM "MyTable"; Only where the column "MyColumn" is "NOT…
Danny Varod
  • 17,324
  • 5
  • 69
  • 111
11
votes
1 answer

Generate id row for a view with grouping

I'm trying to create a view with row numbers like so: create or replace view daily_transactions as select generate_series(1, count(t)) as id, t.ic, t.bio_id, t.wp, date_trunc('day', t.transaction_time)::date…
Random Joe
  • 640
  • 4
  • 10
  • 25
11
votes
4 answers

Cannot update view in PostgreSQL?

My site was developed using Drupal 6 running on a Postgresql 8.3 server on Ubuntu 11.10. Also webmin version 1.590. Now I want to update records in a table, but when I run: UPDATE uac_institution_view SET status = '2' WHERE nid = '9950' it gives me…
srinu
  • 259
  • 3
  • 7
  • 14
10
votes
2 answers

ECommerce Storefront Website: Discovering Similar Products Programmatically

I am developing a storefront web application. When a potential customer is viewing a product on the website, I'd like to suggest a set of similar products from the database automatically (vs requiring an human to explicitly input product similarity…
BenSwayne
  • 16,810
  • 3
  • 58
  • 75
1
2
3
65 66