[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
you want to get 2 rows from 1 entry in the database, which i don't think you can easily do in SQL. you could try something along the lines of: select distinct if(isnull(d1),d2,d1) as thedate, if(isnull(d1),n2,n1) as thename, if(isnull(d1),"paper due","") as thedescription, from (select seminardate as d1, name as n1 from seminars) as t1, (select paperduedate as d2, name as n2 from seminars) as t2 it's a pretty horrible solution though. for a longer-term thing, I'd suggest restructuring the tables if it's not too big a task. you could have a table of seminars seminar_ID, name 1, seminar 1 2, seminar 2 3, seminar 3 4, seminar 4 and a table of events. seminar_ID, date, event_type 1, 01/01/01, seminar 2, 01/02/01, seminar 3, 01/03/01, seminar 4, 01/04/01, seminar 4, 15/02/01, paper deadline then something like select date,name,event_type from seminars join events on seminars.seminar_id=events.seminar_id order by date; will generate the list you want. you could add a view to produce your original table so you don't break all your old queries, but the data entry code would need to be rewritten. my disclaimer is that i know nothing about database optimisation. On 5/15/07, James Fidell <james@xxxxxxxxxxxx> wrote: > Robin Cornelius wrote: > > > Eg i now get > > > > Seminar 1 > > Seminar 2 > > Seminar 4 paper due > > Seminar 3 > > > > but no seminar 4 > > > > Is this possible from a single query, or do a need to generate a temp > > table first with somthing like:- off the top of my head logic not > > valid SQL > > Good point. Perhaps the easiest approach is to create a temporary table > to hold all the information you actually want, then run two inserts into > that table, one for the paper due dates should they exist and the other > for the seminar dates, and then read the temporary table in date order. > > James > > -- > The Mailing List for the Devon & Cornwall LUG > http://mailman.dclug.org.uk/listinfo/list > FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html > -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html