Discussion Locked

Help with SQL statement

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I aksed a similar question a while ago, but need my SQL to do 1 more thing.
1 table (T1) and 2 fields (c1 and c2). Table lists matching colors, so rows are:
red blue
red white
blue red
black red
blue green

Original SQL filtered out the doubles - so in this case 4 rows would be returned (red,blue is the same as blue,red). The additional step is to [a] prompt user to enter color, then [b] display all matching colors. So if user enters "red" a list is returned showing "blue, white, black". If user entered "blue", the returned list would be "red, green".
Do not want to MAKE a table, but a temporary table is fine. If it helps, I'll paste the original SQL below.

5 replies

by mr. origami

Here's the current SQL that filters doubles, but offers no prompts nor does it return just the "matching" color to what was entered:
----------------------
SELECT DISTINCT IIf(myT1_1.C1

by igp

SELECT * FROM T1 WHERE c1 like "%red%"

SELECT * FROM T1 WHERE c1 like "%blue%"

%blue% - any line that contain word "blue"
blue% - any line that begin from word "blue"
%blue - any line that ends on word "blue"
etc....

by sql man

Here is a way to do it in 2 seperate queries. Assuming the query you listed above is named q1, this will give you what you are looking for... if I understand you problem.

SELECT q1.myC1
FROM q1
WHERE (((q1.myC2)=[Enter Color]))
UNION
SELECT q1.myC2
FROM q1
WHERE (((q1.myC1)=[Enter Color]));

This discussion is closed to new replies.