Subject | Re: SQL questions |
---|---|
Author | Fabrice Aeschbacher |
Post date | 2001-06-28T07:00:58Z |
Hi,
SELECT
CO.COUNTRY_NAME
, (SELECT CURRENCY_NAME FROM CURRENCY CU
WHERE CU.ID = CO.CURRENCY1)
, (SELECT CURRENCY_NAME FROM CURRENCY CU
WHERE CU.ID = CO.CURRENCY2)
FROM
COUNTRY CO
Not sure, but I don't think so.
HTH,
Fabrice
> 2- I have 2 tables as follows:One solution is to use "inline select":
> CREATE TABLE CURRENCIES (
> ID INTEGER,
> CURRENCY_NAME CHAR(30),
> PRIMARY KEY(ID));
>
> CREATE TABLE COUNTRIES (
> ID INTEGER,
> COUNTRY_NAME CHAR(30),
> CURRENCY1 INTEGER,
> CURRENCY2 INTEGER,
> PRIMARY KEY(ID),
> FOREIGN KEY (CURRENCY1) REFERENCES CURRENCIES (ID),
> FOREIGN KEY (CURRENCY2) REFERENCES CURRENCIES (ID));
>
> What's the correct SQL SELECT statement that will give me a list of
> countries with the names of both currencies?
SELECT
CO.COUNTRY_NAME
, (SELECT CURRENCY_NAME FROM CURRENCY CU
WHERE CU.ID = CO.CURRENCY1)
, (SELECT CURRENCY_NAME FROM CURRENCY CU
WHERE CU.ID = CO.CURRENCY2)
FROM
COUNTRY CO
> 3- The CREATE TABLE statement supports an EXTERNAL FILE option. Isit
> possible to set the external file name from a stored procedure atrun-time?
Not sure, but I don't think so.
HTH,
Fabrice