0

I have a View called upcoming_birthday which returns a list of people having birthday on the next 7 days (special thanks: Upcoming Birthday based on Current Date and Upcoming Birthdays for this week).

I have a Procedure that takes as input the ID of a company and outputs every customer linked to said company. By link I mean "has a relation with". The origin of those links are sign up by or purchased at (ie customers can be signed up by a company A and, after purchasing something at company B, they'll have a link with companies A and B).

Now I'd like to join those two results. Something like:

SELECT a.* FROM upcoming_birthday AS b INNER JOIN (CALL proc_account_link_company(2)) AS a ON b.id = a.id

Is it doable?

Community
  • 1
  • 1
Marco Aurélio Deleu
  • 4,279
  • 4
  • 35
  • 63
  • I have a question, What is mean of `a` in `SELECT a.* FROM upcoming_brithday` ? Is `a` a column from the table of `upcoming_birthday` ? If yes, so why you write `a` when you write `*` ? –  Jun 15 '15 at 17:53
  • 1
    `a` is the alias of the "second table" (in this case procedure). The meaning is like `SELECT a.* FROM table1 b INNER JOIN table2 a ON b.id = a.id` in such a way that I only care for all columns at **table2** and I don't want any columns from **table1**. – Marco Aurélio Deleu Jun 15 '15 at 17:57
  • 1
    Aha, I thought `,` is between `a` and `*`, Then `a` is a alias name of `CALL proc_account_link_company(2)`, right ? –  Jun 15 '15 at 17:57
  • I don't think you can `JOIN` results of a procedure. Your procedure can write to a temporary/intermediate table instead. That table can be joined with upcoming_birthday table – zedfoxus Jun 15 '15 at 18:23

0 Answers0