August 15, 2007 at 4:52 am
Hi all,
Im fairly new to this, I hope this hasnt been posted before!
I have a table :
From To StatDate
1 2
2 3
3 4
4 5
5 6
Its used for merging, record one was merged to record 2, rec2 merged to rec 3 etc.
What I need is to query the table passing in 6 as a parameter and gat the list above returned. I know how to write queries and pass parameters etc, its just the join syntax I cant figure out. Can anyone help me on this?
Thanks,
Helen
August 15, 2007 at 8:42 am
not enough info to really help yet helen.
the real table definition is much more helpful, as well has the name /definition of the table you are "merging" it with, ie
CREATE TABLE X (XINT INT,MOREINFO VARCHAR(30) )
CREATE TABLE Y (XINT INT,MOREINFO VARCHAR(30) ,XINT INT REFERENCES X(XINT)
it gives us everything we need to evaluate what you want.
As far as a saved query with parameters, you are talking about a stored procedure.
an example might be something like this:
CREATE PROCEDURE PR_EXAMPLE(@DesiredID int)
AS
SELECT X.*,Y.* FROM X INNER JOIN Y ON x.XID = Y.YID AND X.XID = @DesiredID
Lowell
August 16, 2007 at 1:46 am
Hi Lowell,
Problem solved - its a case of querying the table and writing results into a temporary table, then querying that table
Thanks for the reply
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply