Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

error in query ....

Posted on 2002-05-03
6
Medium Priority
?
203 Views
Last Modified: 2009-12-16
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
Comment
Question by:m_adil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:logan69
ID: 6988233
MySQL Doesn't support sub selects.
0
 
LVL 1

Expert Comment

by:logan69
ID: 6988234
You will need to run two queries , one to get the list of emails from tblusage, then echo that into the second query.
0
 
LVL 2

Expert Comment

by:jpoesen
ID: 6988293
indeed, logan69.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Expert Comment

by:peebody
ID: 6988298
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
 

Accepted Solution

by:
peebody earned 150 total points
ID: 6988307
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
 
LVL 1

Expert Comment

by:Rajko
ID: 6995633
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question