SQL queries I don't want to forget

To get events

select CONCAT(e.date,"-",l.name), e.date, l.name as location_name, REPLACE(e.notes,'^M',' '), hour(e.time_start) as start_hour, minute(e.time_start) as start_min, hour(e.time_end) as end_hour, minute(e.time_end) as end_min from locations l, events e where e.location_id=l.id order by date, time_start into outfile '/Volumes/Data/tmp/surveys.txt' fields terminated by ',' enclosed by '"';