I need to use a left outer join to get all of one table, and match it to specific instances of another table. Eg, report all of A, and where A has made a specific kind of B, report the name of that B.
Now, to get the specific B, I need to join three other relations together, and then do a string match. That's easy. I can report the subset of A that has made specific kind of B. I can report all of A. I can report all of A that has made all the kinds of B. But I can't report all of A with specific kinds of B.
I've been trying to use a Left outer join to join A to the subquery that'll tell me the specific kinds of B, and it tells me that the 'b' isn't a valid identifier.
EG: -
-
select A.name, B.name
-
from A LEFT OUTER JOIN (
-
select * from B, C, D where b.foo= c.foo AND c.baa= d.baa
-
AND B.specifictype = 'My Type') ON a.poe= b.poe
-
group by A.name, B.name;
-
it tells me b.poe isn't a valid identifier on line 4. I've tried putting an alias after the subquery, and joining on that alias instead, and it tells me that alias name isn't a valid identifier. Can someone show me where I'm going wrong?
Edit - I'm using Oracle9i EE, SQL*Plus 9.2
6 50960
Hi,
Can you give the query that you tried with aliasing?
That would be more helpful. This query is any way not correct as it has no aliasing.
Post it soon
Cheers
Okay - II'll have to use made-up names, though, because this is a question of an assignment, and my uni takes plagiarism REALLY seriously. (but this is my query with the names all subbed out. ) -
select name, fruitjuicename
-
from student LEFT OUTER JOIN
-
(select * from school, cafeteria, drinks
-
where school.cafID = cafetera.cafID AND
-
cafeteria.drinkID = drink.drinkID AND
-
drinktype = 'fruitjuice') AS juice
-
ON student.schoolID = juice.schoolID
-
group by name, fruitjuicename, studentID;
-
Edit - the query's trying to show: the names of all students, and when they have chosen a fruit juice at lunch, show the name of hte fruit juice, too.
*snip code above*
(too late to edit)
That should actually not have an 'as' after the subquery. I keep forgetting, but for some reason, this version of sql doens't like 'as' when aliasing.
(also, if this is an error because of stupidity on my part, feel free to show me. We haven't actually be *taught* anything more than very basic sql queries for this; we're just expected to magically pick them up by ourselves. So I don't really understand what I'm doing...)
Okay - II'll have to use made-up names, though, because this is a question of an assignment, and my uni takes plagiarism REALLY seriously. (but this is my query with the names all subbed out. ) -
select name, fruitjuicename
-
from student LEFT OUTER JOIN
-
(select * from school, cafeteria, drinks
-
where school.cafID = cafetera.cafID AND
-
cafeteria.drinkID = drink.drinkID AND
-
drinktype = 'fruitjuice') AS juice
-
ON student.schoolID = juice.schoolID
-
group by name, fruitjuicename, studentID;
-
Edit - the query's trying to show: the names of all students, and when they have chosen a fruit juice at lunch, show the name of hte fruit juice, too.
Hi,
As this is an assignment, may be i can guide you rather than give u the direct answer.
In the sub query aliased JUICE, how many columns of same name may come because you have given select * ?
Just try it out on two simple tables with one column (same column name).
If you give
Select * from table1 T1,table2 T2 where T1.col1=T2.col1
Then you will obviously get two columns named col1.
In the juice subquery instead of giving select * . Try selecting those columns you want
eg: select student.cafeid,drink.drinkid....
Try it out and lemme know.
Cheers
Hi,
One more thing
In
ON student.schoolID = juice.schoolID
group by name, fruitjuicename, studentID;
Check if there is a column with the name SchoolID in juice.
What I want you to do is run subquery alone and correct it first.
Try it out and lemme know.
Cheers
Okay, I have the subquery working fine (yes, SchoolID is in juice, because school is in juice).....
(*tries various suggestions*)
I think you're right on the multiple columns - I swapped around the two selects, so that the outer query had "select *" and the inner had the specific stuff (thereby removing multiple columns), and now it works!
Thanks for your help!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dam |
last post by:
Using SqlServer :
Query 1 :
SELECT def.lID as IdDefinition,
TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour
FROM serveur.Data_tblDEFINITIONTABLEDECODES def,...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Ian Boyd |
last post by:
i know nothing about DB2, but i'm sure this must be possible.
i'm trying to get a client to create a view (which it turns out is called a
"Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
|
by: mike |
last post by:
I'm using postgresl 7.3.2 and have a query that executes very slowly.
There are 2 tables: Item and LogEvent. ItemID (an int4) is the primary key
of Item, and is also a field in LogEvent. Some...
|
by: Doug |
last post by:
Hi,
I'm more familiar with MSSQL than Access syntax and have run into a problem
with correctly putting ( )'s around the joins in a 3 table query. I want to
INNER JOIN lenders and accounts and...
|
by: media.opslag |
last post by:
Hi,
How can i get this to work in access / jet sql ??? Someone??
SELECT
tbl1.,
tbl2.
FROM tbl1
left outer join tbl2 on
|
by: Sascha.Moellering |
last post by:
Hi,
I receive the error code SQL0338N if I try to compile this statement
(part of the statement):
.... left outer join lateral
(SELECT * FROM LIZSYSABA.VWZL0359TBS WHERE tbs_name = CASE WHEN...
|
by: nico3334 |
last post by:
I have a query that currently pulls data from a main table and a second table using LEFT OUTER JOIN. I know how to do make another LEFT OUTER JOIN with the main table, but I want to add another LEFT...
|
by: teneesh |
last post by:
Here I have a code for a view that has been created by a developer on my team. I am trying to use the very same code to create a view for a different formid/quesid. But I cannot figure out how this...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |