• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

error in query ....

Hi,
I'm using PHP with mySQL and getting an error while executing the following query. this query is running fine in SQL Server but gives an error in mySQL.

qry is ....
SELECT DISTINCT Email FROM sw_users WHERE sw_users.Email NOT IN (SELECT DISTINCT email from tblusage))

and the err is
You have an error in your SQL syntax near 'SELECT DISTINCT email from tblusage))

why is it so? why is it running fine in SQL Server and not in mySQL ???

0
m_adil
Asked:
m_adil
1 Solution
 
logan69Commented:
MySQL Doesn't support sub selects.
0
 
logan69Commented:
You will need to run two queries , one to get the list of emails from tblusage, then echo that into the second query.
0
 
jpoesenCommented:
indeed, logan69.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
peebodyCommented:
This should work:

SELECT DISTINCT sw_users.Email FROM sw_users LEFT JOIN tblusage ON sw_users.Email=tblusage.email WHERE tblusage.email = NULL
0
 
peebodyCommented:
sorry, should be: SELECT DISTINCT sw_users.Email FROM sw_users LEFT JOIN tblusage ON sw_users.Email=tblusage.email WHERE
tblusage.email IS NULL
0
 
RajkoCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now