This is, almost assuredly, not the cause... nor the cure, but try:
SELECT *
FROM LeaseLOS as L
WHERE (L.WellID IN (select w.wellid from wells as w where w.leaseid in (38, 40))
As said, that's probably not it, but you may be suffering from ambiguous references to both "leasid" and "wellid".
[red]Note:[/red] [gray]The above comments are the opinionated ravings of Mr3Putt. As such, Mr3Putt accepts no responsibility for damages, real or contrived, resulting from acceptance of his opinions as fact.[/gray]