Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert an OR condition within multiple AND

Author  Topic 

nebj00la
Starting Member

2 Posts

Posted - 2009-02-25 : 15:17:09
Existing code:
$raw_data = db_fetch_assoc("select field_value,snmp_index from host_snmp_cache where snmp_index in (select snmp_index from host_snmp_cache where snmp_index not in (select snmp_index from graph_local WHERE host_id =" . $host_id . " and graph_template_id = " . $data_query_graphs[0]['graph_template_id'] . ") and host_id=" . $host_id . " and field_name='ifOperStatus' and field_value='Up' and snmp_query_id=" . $snmp_query["id"] .") and host_id=" . $host_id . " and field_name='$field_name' and snmp_query_id=" . $snmp_query["id"]);


I need the query to work if field_name is 'ifOperStatus' and field_value is 'Up'; OR if field_name is 'nsIfStatus' and field_value is '1'. nsIfStatus is new to the query.

Thanks in advance!

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-25 : 15:28:46
Maybe this:

select field_value,snmp_index from host_snmp_cache
where snmp_index in
(select snmp_index from host_snmp_cache
where snmp_index not in
(select snmp_index from graph_local
WHERE host_id =" . $host_id . "
and graph_template_id = " . $data_query_graphs[0]['graph_template_id'] . ")
and host_id=" . $host_id . "
and ((field_name='ifOperStatus' and field_value='Up') or (field_name='nsIfStatus' and field_value='1'))
and snmp_query_id=" . $snmp_query["id"] .")
and host_id=" . $host_id . "
and field_name='$field_name'
and snmp_query_id=" . $snmp_query["id"]

Go to Top of Page

nebj00la
Starting Member

2 Posts

Posted - 2009-02-25 : 15:41:22
I'll give it a try. Thanks!
Go to Top of Page
   

- Advertisement -