Reply to Re: Help with Select and IN

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация