[SQL] Hidden Select

2001-06-08 Thread Luis Sousa
I have a query that joins several table with some restrictions. I want to take out those restrictions from the query and create a view that does not show the fields that are used to restrict the data, but in some way, i can restrict that data when i call the view. Is it possible to hide some fiel

[SQL] Rule ON DELETE, to perform to DELETE querys !

2001-06-08 Thread Luis Sousa
I have a view over a join of tables and when it's performed over the view a delete i want to delete records in two different tables. The code that i wrote was: CREATE RULE "deletetables" AS ON DELETE TO "tables" DO INSTEAD ( DELETE FROM table2 WHERE id = OLD.

Re: [SQL] Getting row with id=max(id)

2001-06-08 Thread Tom Lane
Gerald Gutierrez <[EMAIL PROTECTED]> writes: > I'd like to get the row with ID=4. I've tried: > SELECT * FROM mytable WHERE id=(SELECT MAX(id) FROM mytable); > The subquery can take a /really/ long time on a table that is large. The query: > SELECT * FROM mytable ORDER BY id DESC LIMIT 1; > doesn'

[SQL] Index usage

2001-06-08 Thread Subra Radhakrishnan
Hi All, The index created by me is not being used while doing select. I found that out by using the EXPLAIN. For example: Table department has dept_num dept_desc Table 'employee' looks like this: emp_num primary key, emp_name, dept_num (this i

Re: [SQL] Index usage

2001-06-08 Thread Stephan Szabo
On Fri, 8 Jun 2001, Subra Radhakrishnan wrote: > Hi All, > > The index created by me is not being used while doing > select. I found that out by using the EXPLAIN. For > example: > > Table department has > > dept_num > dept_desc > > > Table 'employee' looks like this: >