Hi all,

I'm having a hard time trying to create this query.
I have two tables:
log - columns: id, name and date
info - columns: id, tag, value

i.e.:
log
id | name                  | date
-------------------------------------
1  | machine_name          | 07/31/06
2  | another_machine_name  | 08/01/06

info
id  | tag       | value
--------------------------------
1   | release   | release_name
1   | arch      | 32-bit
1   | mode      | amode
2   | release   | release_name
2   | arch      | 64-bit
2   | mode      | amode

Basically, the info table contains detailed information of 
each machine in the log table. The same machine can appear 
more than once, but with a different id number, that's why
I use group by in the following query:

 select lo.name, inf.value, lo.date from log as lo 
 join info as inf on lo.id=inf.id where (inf.tag='release' 
 and inf.tag='arch') AND lo.id in (select max(id) 
 from log group by name) order by name

Everything worked well, but now I've been asked to display
this data based on "mode" (located in the info table). 
I don't have to display mode, but I have to use it as 
a condition since there are more than two modes. 
I'm not sure how to add this condition to the query, though. 
I tried adding this to the query above but, of course, 
it didn't work:
 
 AND inf.id in (select id from info where value LIKE %s)

I'd appreciate any help
Thanks,
Patricia



_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to