I want to write something like that, but alas, it does not work!

SELECT `year` FROM `success` JOIN (SELECT YEAR(now()) as `year`) `a`; 

It is clear that I join not quite the table, but how then to be?

  • Give an example of the data that you initially have, and an example of the result you want to get - Dmitry Dovgopoly
  • I don’t know how to discard it, but I can describe what is and what I want to see. The success table has the fields id, year (A simplified version of the larger one is not needed) And the “table” a, which contains the current date

1 answer 1

If I understand the task correctly, then we have a table of success

 id year -------------------- 1 1889 2 2007 3 3015 

We want to get the following result

 year current_year -------------------------- 1889 2016 2007 2016 3015 2016 

Then we will approach the request

 SELECT `year`, YEAR(getdate()) as `current_year` FROM `success`; 
  • Thank you, I originally invented some kind of bicycle) - MaximPro
  • You can also use the bike: SELECT success. *, year FROM success , (SELECT YEAR (now ()) as year ) a ; - msi