|
Posted by ZeldorBlat on 03/19/07 13:02
On Mar 19, 8:39 am, "Giorgio" <FJMarti...@googlemail.com> wrote:
> Can someone tell me options to do this statment because this one does
> not work!
>
> SELECT Name FROM tbl_J
> WHERE J_ID IN
> (SELECT J1, J2, J3, J4, J5, J6
> FROM tbl_CJ
> WHERE CJ_ID =23515) ORDER BY Name
I won't go into why this suggests a problem with your model, but I
think you want something like this:
SELECT Name FROM tbl_J
WHERE J_ID IN
(SELECT J1
FROM tbl_CJ
WHERE CJ_ID =23515
UNION
SELECT J2
FROM tbl_CJ
WHERE CJ_ID =23515
....
UNION
SELECT J6
FROM tbl_CJ
WHERE CJ_ID =23515) ORDER BY Name
Alternatively you could OR them all together:
SELECT Name FROM tbl_J
WHERE J_ID IN
(SELECT J1
FROM tbl_CJ
WHERE CJ_ID =23515)
OR J_ID IN
(SELECT J1
FROM tbl_CJ
WHERE CJ_ID =23515)
....
OR J_ID IN
(SELECT J6
FROM tbl_CJ
WHERE CJ_ID =23515)
ORDER BY Name
[Back to original message]
|