Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Making two QUERIES as one

$
0
0
Hi everybody, I am working with SQLite and I am trying to make a single QUERY that interrogates twice the same table.
Firstly I need to select a row from a particular key "ID" creating a VIEW selecting all the values I need (val_1, val_2, val_3, val_4).
I then selected with a second QUERY all the "val" from the "test" table with the same attributes of the VIEW.
need to make a single QUERY from the two. Any idea?

Here are the two queries:

create view view_test as
Code:

select 'test'."ID",
'test'."val_1",
'test'."val_2",
'test'."val_3",
'test'."val_4"
from "test"
where 'test'."ID" = 8

Code:

select 'test'."ID",
'test'."val_1",
'test'."val_2",
'test'."val_3",
'test'."val_4"

from "test", "view_test"

where 'test'."val_1" = 'view_test'."val_1" and
'test'."val_2" = 'view_test'."val_2" and
'test'."val_3" = 'view_test'."val_3"  and
'test'."val_4" = 'view_test'."val_4



Thank you!

Viewing all articles
Browse latest Browse all 13329

Trending Articles