Postgresql Issue - postgresql

I'm trying to do a join with a LEFT(column,5) but I am not getting the syntax right. Of the code below how should I be accomplishing this? I'm usually doing MSSQL so I'm not sure if the syntax is different or I'm just doing something wrong.
select * from ofbiz.supplier_product a
join ofbiz.supplier_product b on a.(LEFT(prod_catalog_id,5)) = b.party_id
Thanks

Try this:
select * from ofbiz.supplier_product a
join ofbiz.supplier_product b on LEFT(a.prod_catalog_id,5) = b.party_id

Related

couchbase query returning empty answer

hello im trying to get query from couchbase and getting a blank answer
this is my data :
this is my data and its keep going like that
i cant get any tagnames and im kinda lost so i would be glad to get any help
i tryed
:
SELECT b.*
FROM mekorot[0] b
WHERE node.kind = 2
and im still getting :
{
"results": []
}
I don't think IN is doing what you think it should be doing. IN is meant for queries like SELECT * FROM foo WHERE x IN ['array0','array1']. I'm not sure why this query isn't giving you parsing errors, but try this instead:
SELECT b.*
FROM backetname b
WHERE b.node.kind = 2
Here's some screenshots showing it in action:

How can i show all vertices in orientdb except where #class="movie"?

Hi there i want to show all Vertices except the ones called movie.
my statement so far was
SELECT * FROM V WHERE NOT #class="movie"
but unfortunately the response does not contain any records. can anybody explain this to me ? :) Thank you :)
what version are you using? If I try in 3.0.0 your query work but you have to use "class" :
SELECT * FROM V WHERE NOT #class="movie"
Cool i solved it by using:
SELECT * FROM V WHERE #class!="movie"
thanks for your help Idacrema :)

Issue with the join expression in Access 2013

Given below is the sample of my code. When I tried to switch to the design view it gives me an error:
"Microsoft Access can't represent the join expression a.Course_name=b.Course_name in Design view".
When I searched this error on stackoverflow I found one post. According to the post the solution is given in this link (http://support.microsoft.com/kb/207868). According to this link, try to remove extra parenthesis (especially nested parenthesis) and problem will be resolved. However, in my query I don't have nested parenthesis. So I don't know how to fix it. Any help would be appreciated.
SELECT a.Course_name, COUNT(b.Student_code) AS [Total], Format(b.Retrieved_date,"mmmm yyyy") AS [Month]
FROM Course AS a LEFT JOIN (SELECT b.Course_name, b.Student_code, b.Retrieved_date FROM pending-enrolment AS b WHERE b.Retrieved_date BETWEEN [Forms]![ParameterForm]![txtBeginDate] AND [Forms]![ParameterForm]![txtEndDate]) b
ON a.Course_name=b.Course_name
GROUP BY a.Course_name, b.Retrieved_date
;
Try the following code (tested and works 100%):
SELECT Course.Course_name, Count(b.Student_code) AS CountOfStudent_code,
Format([b].[Retrieved_date],"mmmm yyyy") AS [Month]
FROM Course
LEFT JOIN
(
SELECT [pending-enrolment].Course_name, [pending-enrolment].Student_code,
[pending-enrolment].Retrieved_date
FROM [pending-enrolment]
WHERE ([pending-enrolment].Retrieved_date
Between [Forms]![ParameterForm]![txtBeginDate]
And [Forms]![ParameterForm]![txtEndDate])
) AS b ON Course.Course_name = b.Course_name
GROUP BY Course.Course_name, Format([b].[Retrieved_date],"mmmm yyyy");

Sailsjs-Waterline : How to filtering after populate?

I'm using sailjs + waterline, how to filtering data after populate models? here i try my code and doesn't work :
Approductbranch
.find({deleted:1})
.populate("mproduct_id",{where:{deleted:1}})
.paginate({page:currpage,limit:utils.RowPerPage})
.exec(callback)
in my code above, i want to execute sql like this :
select * from approductbranch a
inner join mproduct a
on a.id = a.mproduct_id
where a.deleted = 1
and b.deleted = 1
how to do this? thank! :)
Good question.
There currently isn't a way to do this directly, but there is an outstanding feature request in the Waterline repository that you can share your thoughts in.
I think you can do like this:
Approductbranch
.find({deleted:1})
.populate("mproduct_id",{deleted:1, skip:currpage * utils.RowPerPage, limit:utils.RowPerPage})
.exec(callback)
it will be OK!
You can filter a set of values before you populate. This is more performant since you're not getting more values than you need: https://github.com/balderdashy/sails-docs/blob/master/reference/waterline/queries/populate.md

Eager loading in Entity Framework fails on complex query

The following query fails to load the tables when I execute it:
IEnumerable<Bookmark> tempBookmarks = ListBookmarksByUserID(userID);
IEnumerable<CandidateWithBookmarks> results = (from c in _internshipEntities.CandidateSet
.Include("education")
.Include("progress")
.Include("contacts")
.Include("availability")
.Include("hosttypes")
.Include("hostsizes")
.Include("hostcapacities")
.Include("hoststates")
.Include("users")
join b in tempBookmarks on c.ID equals b.candidates.ID
select new CandidateWithBookmarks()
{CandidateObject = c, BookmarkObject = b});
return results;
I have found some articles related to the problem, namely Alex James' article "How to make Include really Include". The solution comes with one caveat:
For this to work your final select must be entities, i.e. select post rather than select new {…}
Which is obviously an issue for the above block of code. Are there any other known work-arounds for this issue that won't break eager loading?
I think I solved this but it might only work for this specific instance, by moving the includes after the join, the query appears to work:
IEnumerable<CandidateWithBookmarks> results = (
from b in tempBookmarks
join c in _internshipEntities.CandidateSet
.Include("education")
.Include("progress")
.Include("contacts")
.Include("availability")
.Include("hosttypes")
.Include("hostsizes")
.Include("hostcapacities")
.Include("hoststates")
.Include("users")
on b.candidates.ID equals c.ID
select new CandidateWithBookmarks(){CandidateObject = c, BookmarkObject = b});
Edit: Another query I have similar to this requires an outer join as well, which creates some issues since it then matters what you join to what, unlike this example, but it's still doable.