In most SQL products, I can select from no table or from a dummy table like this:
-- Oracle
SELECT 1 FROM DUAL
-- Many other SQL products (including Ingres)
SELECT 1
Sometimes, I want to add a condition to the above statement, in order to retrieve 0 or 1 record, depending on the condition
-- Oracle
SELECT 1 FROM DUAL WHERE 1 = 0
-- Many other SQL products (but not Ingres)
SELECT 1 WHERE 1 = 0
But the above does not work for Ingres 10.0. How can I do it?
The DUMMY table is provided as a table that always has exactly one row. This can be useful for extracting information from the database, as in the following example that gets the current user ID and the current date from the database. The DUMMY table is a SQL Anywhere system table.
The table has a single VARCHAR2(1) column called DUMMY that has a value of 'X'. MySQL allows DUAL to be specified as a table in queries that do not need data from any tables. In SQL Server DUAL table does not exist, but you could create one.
Dual is a table that is created by Oracle together with data dictionary. It consists of exactly one column named “dummy”, and one record. The value of that record is X. You can check the content of the DUAL table using the following syntax.
The DUAL table is a special one-row, one-column table present by default in Oracle and other database installations. In Oracle, the table has a single VARCHAR2(1) column called DUMMY that has a value of 'X'. It is suitable for use in selecting a pseudo column such as SYSDATE or USER.
I've not used Ingres but I assume from your question that a FROM
is mandatory if there is a WHERE
? In that case how about
SELECT 1 FROM (SELECT 1 AS C) AS T WHERE 1 = 0
Or
SELECT CASE WHEN 1 = 0 THEN 1 ELSE 0 END
(The last one will always return a row but allow you to check a condition)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With