Solved

error in query ....

Posted on 2002-05-03
6
197 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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 50 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

785 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