I have 2 tables - a course that contains the id and the name of the courses and tagCourse that contain tags for each course.
course tagcourse ------------ ---------------- PK id_course PK tag name PK, FK id_course
I would like to write a function that searches for courses by a given array of tags and returns them by the number of matching tags. However, I do not know how to write correctly and efficiently. Please help me.
t
CREATE OR REPLACE FUNCTION searchByTags(tags varchar[]) RETURNS SETOF..... RETURN QUERY SELECT * FROM course c INNER JOIN tagcourse tc ON c.id_course = tc.id_course WHERE ??? ORDER BY ??? END....
sql sql-order-by postgresql aggregate set-returning-functions
catchmeifyoucan Mar 27 '13 at 16:40 2013-03-27 16:40
source share