Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


modify sql statement from *= to left outer join


modify sql statement from *= to left outer join

Author
Message
carol.d
carol.d
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 12
I am trying to convert to left outer join syntax a sql statement that works as expected using *= syntax.

current sql
SELECT labtrans.transdate,
labtrans.laborcode,
labtrans.regularhrs,
labtrans.startdate,
labtrans.craft,
labtrans.refwo,
task.worktype,
task.parent,
parent.wonum,
parent.location,
parent.worktype,
matusetrans.itemnum,
matusetrans.mrnum,
matusetrans.transdate,
matusetrans.actualdate,
matusetrans.issuetype,
matusetrans.description,
matusetrans.storeloc,
matusetrans.refwo,
matusetrans.linetype,
labor.personid,
matusetrans.issueto,
asset.eq1

FROM labtrans,
workorder task,
workorder parent,
labor,
matusetrans,
asset

WHERE ( labtrans.refwo = task.wonum ) and
( task.parent = parent.wonum ) and ( labtrans.laborcode = labor.laborcode ) and
( labtrans.refwo *= matusetrans.refwo) and
(convert (char( 20 ),labtrans.startdate,6) *= convert (char( 20 ),matusetrans.transdate,6)) and
(matusetrans.linetype = 'WAREHOUSE ITEM' or matusetrans.linetype = 'TOOL ROOM') and
(labor.personid *= matusetrans.issueto) and (parent.worktype <> 'A') and
(labtrans.craft >= '611-ELEC' and labtrans.craft <= '619-SMWE') and (task.assetnum *= asset.assetnum) and
( labtrans.startdate >= :from_date and labtrans.startdate <= :thru_date )



conversion so far....

SELECT labtrans.transdate,
labtrans.laborcode,
labtrans.regularhrs,
labtrans.startdate,
labtrans.craft,
labtrans.refwo,
task.worktype,
task.parent,
parent.wonum,
parent.location,
parent.worktype,
matusetrans.itemnum,
matusetrans.mrnum,
matusetrans.transdate,
matusetrans.actualdate,
matusetrans.issuetype,
matusetrans.description,
matusetrans.storeloc,
matusetrans.refwo,
matusetrans.linetype,
labor.personid,
matusetrans.issueto,
asset.eq1

FROM { oj labtrans left outer join matusetrans ON ( labtrans.refwo = matusetrans.refwo) and
(convert (char( 20 ),labtrans.startdate,6) = convert (char( 20 ),matusetrans.transdate,6)) and
(matusetrans.linetype = 'WAREHOUSE ITEM' or matusetrans.linetype = 'TOOL ROOM')} ,
{ oj workorder task left outer join asset ON (task.assetnum = asset.assetnum) } ,
workorder parent,
labor
WHERE ( labtrans.refwo = task.wonum ) and
( task.parent = parent.wonum ) and
(parent.worktype <> 'A') and
(labtrans.laborcode = labor.laborcode) and
(labor.personid *= matusetrans.issueto) and
(labtrans.craft >= '611-ELEC' and labtrans.craft <= '619-SMWE') and
( labtrans.startdate >= :from_date and labtrans.startdate <= :thru_date )

I haven't successfully converted the left outer join of the labor and matusetrans tables.
I need to join labtrans to labor to have a data column that will join with matusetrans.
If I alias matusetrans {oj labor left outer join matusetrans issue on labor.personid = issue.issueto} I don't get a syntax error
but I am not getting what I want.

Thanks for any help.

Carol
Dan.Humphries
Dan.Humphries
SSC Eights!
SSC Eights! (827 reputation)SSC Eights! (827 reputation)SSC Eights! (827 reputation)SSC Eights! (827 reputation)SSC Eights! (827 reputation)SSC Eights! (827 reputation)SSC Eights! (827 reputation)SSC Eights! (827 reputation)

Group: General Forum Members
Points: 827 Visits: 1212
Are you running this through somehting other than Microsoft SQL server? "{of" is not somehting SQL would understand to my knowledge. Also you have spaces in your table names which would have to be in cased in [].

Dan

If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8582 Visits: 18157
I'm sure you're not using SQL Server, but I guess this should work as expected.

SELECT labtrans.transdate,
labtrans.laborcode,
labtrans.regularhrs,
labtrans.startdate,
labtrans.craft,
labtrans.refwo,
task.worktype,
task.parent,
parent.wonum,
parent.location,
parent.worktype,
matusetrans.itemnum,
matusetrans.mrnum,
matusetrans.transdate,
matusetrans.actualdate,
matusetrans.issuetype,
matusetrans.description,
matusetrans.storeloc,
matusetrans.refwo,
matusetrans.linetype,
labor.personid,
matusetrans.issueto,
asset.eq1

FROM labtrans
JOIN workorder task ON labtrans.refwo = task.wonum
JOIN workorder parent ON task.parent = parent.wonum
JOIN labor ON labtrans.laborcode = labor.laborcode
LEFT JOIN matusetrans ON labtrans.refwo = matusetrans.refwo
AND convert (char( 20 ),labtrans.startdate,6) = convert (char( 20 ),matusetrans.transdate,6)
AND (matusetrans.linetype = 'WAREHOUSE ITEM' or matusetrans.linetype = 'TOOL ROOM')
AND labor.personid = matusetrans.issueto
LEFT JOIN asset ON task.assetnum = asset.assetnum

WHERE (parent.worktype <> 'A') and
(labtrans.craft >= '611-ELEC' and
labtrans.craft <= '619-SMWE') and
( labtrans.startdate >= :from_date and labtrans.startdate <= :thru_date )




Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
carol.d
carol.d
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 12
thanks that works.

the syntax I provided {oj } was default syntax created when using powerbuilder graphic interface and then converting to syntax.
That's where the *= came from. I am using sql server so if that is unusual i guess it is a powerbuilder thing.
I have used the {oj } syntax in other places and it is working fine.

Thanks so much for your help.
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8582 Visits: 18157
There might be something wrong in the configuration of Powerbuilder (I've never used it). The variables are wrong as well (there's a : where a @ should go).


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search