Community discussion forum

mysql - select multiple rows

  • 8 months ago
    I have a table with date and location fields. The dates are YYYY-MM-DD because I need the detail for later, but for now I want to show my data thus: YEAR1 location1 location2 location2 YEAR2 location4 location5 location6 location7 YEAR3 location8 location9 etc. Does anyone know how this can be achieved? At the moment I have multiple queries in the form "SELECT * ,YEAR(mydate) AS newdate FROM mytable WHERE YEAR(fieldtrip_date) = 'YEAR1'" This works, but I need a separate query for each year. Thanks in advance, Ian
    Post was edited on 18/02/2009 06:07:06 Report abuse
  • 8 months ago
    Hi This is simon I am new to this forum. I think this site is providing information about Talk in your language. I think this site is to be useful to whom wants to know about languages they require to see this. ================ simon [free phr](http://www.healthycircles.com)
  • 8 months ago
    Hi This is simon I am new to this forum. I think this site is providing information about Talk in your language. I think this site is to be useful to whom wants to know about languages they require to see this. ================ simon [phr](http://www.healthycircles.com)
  • 8 months ago
    Hi, I'm not shure I anderstand your question. Do you mean something like this - SELECT * ,YEAR(mydate) AS newdate FROM mytable oredr by fieldtrip_date or like this SELECT * ,YEAR(mydate) AS newdate FROM mytable WHERE YEAR(fieldtrip_date) in ('YEAR1','YEAR2','YEAR3') or SELECT * ,YEAR(mydate) AS newdate FROM mytable WHERE YEAR(fieldtrip_date) between 'YEAR1' and 'YEAR3'

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!