June 26, 2007 at 4:30 am
Hi,
I am having some problems creating a stored procedure that performs a select and joins two tables together. OK here goes my explanation;
I have two tables GL_Entry and GL_Register.
GL_Entry contains the following columns and data;
From Entry No_------- To Entry No_ --------- Creation Date
617700------------------------617705---------------2007-06-26
GL_Register contains the following;
Entry No_-------------Column2----------------Column3
617700---------------A Row -------------------More data
617701---------------A Row -------------------More data
617702---------------A Row -------------------More data
617703---------------A Row -------------------More data
617704---------------A Row -------------------More data
617705---------------A Row -------------------More data
OK. The entry numbers are unknown and I need to return ALL entry no's based on the creation date for a particular day by passing in a variable to the stored proc.
Any help would be greatly appreciated.
Thanks
June 26, 2007 at 4:36 am
You could join using a between clause.
Select
xxx
From
GL_Entry ENT
JOIN GL_Register REG ON REG.Entry_NO Between ENT.From_Entry_NO and ENT.From_Entry_NO
where
ENT.CreationDate = @CreationDate
Should work...
Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!
June 26, 2007 at 6:00 am
Thank you very much! I did not know I could join using a between...learn something new every day
June 26, 2007 at 6:06 am
you can pretty much use any valid syntax in a join. Most of the time it will not give you meaningful results but will parse.
Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply