Home » SQL & PL/SQL » SQL & PL/SQL » Find out the column values based on primary key from one table
Find out the column values based on primary key from one table [message #690207] Sun, 08 December 2024 11:01 Go to next message
vasu.bods703
Messages: 2
Registered: March 2015
Location: Chennai
Junior Member
Hi Experts,

I have a view with selecting columns from multile tables. In that one table column value is not matching with Test and Prod.
So i need to find out that not matching value coming from which table and that table primary key.

Example:

View
----
create view demo_view
as
select
A.Product_id
B.Customer
C.Product_desc
D.cust_desc
from A left join B
on a.product_id=b.product_id
left join c
on a. cust_id=c.cust_id
left join D
on a.member_id=d.member_id.

when i select product,customer,product_desc,cust_desc from dempo_view where product=12345;(That particuler product(12345)
product_desc value is coming wrong)

but when i cehck product_desc from C table. it is producting multiple values, I need to find out based on c table primary
key i have to look  exact value of product_desc

if my question is not undurstand, please let me know

Thanks,
Vasu



Re: Find out the column values based on primary key from one table [message #690208 is a reply to message #690207] Sun, 08 December 2024 12:00 Go to previous messageGo to next message
John Watson
Messages: 8962
Registered: January 2010
Location: Global Village
Senior Member
I can't understand what you are trying to do or what the problem is. Part of this is because you have named your tables A, B, C, and D which gives no hint of what they actually are. I'm guessing that B is a fact table and that A, C, and D are dimension tables. Is that correct? If you can explain this, then perhaps someone can help.
Re: Find out the column values based on primary key from one table [message #690209 is a reply to message #690207] Sun, 08 December 2024 12:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

And the moderator bit:

Please read the OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.

Also always post your Oracle version, with 4 decimals (query v$version), as often solution depends on it.

With any SQL or PL/SQL question, please, post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your tables and data. Explain with words and sentences the rules that lead to this result.

Re: Find out the column values based on primary key from one table [message #690210 is a reply to message #690209] Sun, 08 December 2024 16:00 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3303
Registered: January 2010
Location: Connecticut, USA
Senior Member
Well, product description comes from table C but look at table C join condition:

left join c
on a. cust_id=c.cust_id
This doesn't make much sense. I'd expect:

left join c
on a.product_id = c.product_id
SY.
Re: Find out the column values based on primary key from one table [message #690211 is a reply to message #690210] Mon, 09 December 2024 02:43 Go to previous message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
Though if C is a master list of products it does beg the question of why it has a cust_id column.
Previous Topic: How to Get the Program Name in 11g version
Next Topic: Help Needed in Calculation Logic function
Goto Forum:
  


Current Time: Thu Dec 26 12:23:32 CST 2024