-
Query Help
Hi Everyone am very new to SQL and self teaching myself until I can take a SQL class hopefully this spring. Came across this example and having been trying to figure it out.
I've made two tables.
The first table (X) has columns X1 and X2.
The second table (Y) has columns X and D.
Both X1 and X2 have a foreign key constraint referring to column X in table Y.
Write a query to determine all X1,X2 such that X1 and X2 have different values for D.
I've got the two tables but am not sure how to write the query. Any help will be appreciated. This is what I have so far.
query="
CREATE TABLE X
(ID INTEGER PRIMARY KEY),
X1 CHAR(20),
X2 CHAR(20),
FOREIGN KEY (X1) REFERENCES Y(X)
FOREIGN KEY (X2) REFERENCES Y(X)
;
CREATE TABLE Y
(ID INTEGER PRIMARY KEY),
X CHAR(20),
D CHAR(20),
;
"
sqldf(query)
-
-
Originally Posted by pyrotaz
Figured it out thanks
Posting the solution would help out others...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|