Re: [SQL] SQL CASE Statements

2005-08-22 Thread Halley Pacheco de Oliveira
Dear Lane, is that what you want? CREATE TABLE network_nodes ( node_id SERIAL PRIMARY KEY, node_name VARCHAR, default_gateway_interface_id INTEGER ); CREATE TABLE router_interfaces ( interface_id SERIAL PRIMARY KEY, node_id INT REFERENCES network_nodes ); CREATE VIEW current

Re: [SQL] SQL CASE Statements

2005-08-22 Thread Lane Van Ingen
Halley, here is a sample for you that might help; the purpose of this function was to set an indicator of '1' or '0' (true or false) on a router interface if the router interface ID was the same as the default gateway for the Router node ID: create view current_default_gateways_v (router_id, defau

Re: [SQL] SQL CASE Statements

2005-08-20 Thread Halley Pacheco de Oliveira
> Has anybody done this? If so, can you send me a sample? CREATE TEMPORARY TABLE fruits (id SERIAL, name TEXT); INSERT INTO fruits VALUES (DEFAULT, 'banana'); INSERT INTO fruits VALUES (DEFAULT, 'apple'); CREATE TEMPORARY TABLE food (id SERIAL, name TEXT); INSERT INTO food VALUES (DEFAULT, 'apple'

Re: [SQL] SQL CASE Statements

2005-08-18 Thread Dmitri Bichko
I am not sure what you are asking... SELECT CASE WHEN EXISTS (SELECT foo FROM bar WHERE baz = 'a') THEN 1 ELSE 0 END; Or SELECT CASE WHEN 'a' = ANY (SELECT froo FROM bar) THEN 1 ELSE 0 END; Both work, but that's pretty much what you had already - am I missing what you are trying to achieve? Th