September 20, 2008 at 9:36 am
Hi Guys. Would anyone know how I could refernce the contents of a certain cell in a certain table to use as the filter information for a query in a view I am writing? thanks
September 20, 2008 at 8:15 pm
Sure... what's the name of the table, the PK that identifies the row, and the column name of that certain cell?
--Jeff Moden
Change is inevitable... Change for the better is not.
September 21, 2008 at 8:51 am
The table name is "TheValues" , the PK field is [Desc] and the value in the PK field needs to "ComPeriod". Then it is the value in the "TheData" field that I will want to use.
September 21, 2008 at 6:26 pm
SELECT sot.*
FROM dbo.SomeOtherTable sot
INNER JOIN dbo.TheValues tv
ON sot.TheData = tv.TheData
WHERE tv.[Desc] = 'ComPeriod'
--Jeff Moden
Change is inevitable... Change for the better is not.
September 21, 2008 at 6:39 pm
So do I place that right into the filter critera box in the query designer?
September 21, 2008 at 6:42 pm
Heh... Sorry, I wouldn't know. I don't use query designer to design queries. What I gave you is the "core" of the query that you'd end up with.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 21, 2008 at 6:54 pm
Ok... here it is... had to look. Copy the query I gave you and paste it into the SQL pane of the query designer. Make sure the table names and columns are correct and it should automatically draw the diagram in the Diagram pane and automatically populate the Criteria Pane.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 21, 2008 at 7:24 pm
Ummm... ok... now I understand the latest question...
The answer is that isolation of the "cell" and using it as a criteria is done as a combination of a JOIN between the tables in the Diagram Pane and a criteria in the Criteria Pane. The code I gave you is what the Query Designer would return if you did those things.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 21, 2008 at 8:25 pm
Thanks for the awesome help. Works great. After I saw what happend in the query designer after I dropped in your sql statement I felt a little foolish asking the question. It was only a click or two away form what I had tried. Thanks for your help again.
Kelly
September 21, 2008 at 8:29 pm
You bet. Thanks for the feedback, Kelly. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply