Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT : Need Help on select .. where .. in ( select...)

Status
Not open for further replies.

ssakhri

Programmer
Apr 12, 2001
1
DZ
Hello,
I use mysql and want to use select function as the following :

select E.*,c.Name,V.Name,P.Name
from Entreprise E,Categorie C,Ville V,Pays P
where (C.CategoryCode=E.SubCategoryCode)and(V.CodeVille=E.CodeVille)and(P.CodePays=V.CodePays)and
(E.ID in(select ID From table1 where ID>15)
)

is there a way to use IN function or INTERSECT ?
Please it's really urgent,
Thank you
 
MySQL does not (yet) support subselects. However, you can usually work around this. In your example, try this:
Code:
SELECT Enterprise.*, Categorie.Name, Ville.Name, Pays.Name
FROM Enterprise
INNER JOIN Categorie
  ON Enterprise.SubCategoryCode = Categorie.CategoryCode
INNER JOIN Ville
  ON Enterprise.CodeVille = Ville.CodeVille
INNER JOIN Pays
  ON Ville.CodePays = Pays.CodePays
INNER JOIN table1
  ON Enterprise.ID = table1.ID
WHERE table1.ID>15;

Generally, using JOINs is easier than long WHERE clauses.

Hope this helps,
-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top