473,486 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with subquery WHERE EXISTS or IN

3 New Member
I have tried 2 variations of this query and cannot get it to work due to the fact I cant use "where email in". I get this error
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS".

I am trying to import records from the marketingmaster table that allows duplicate entries in the email column to the addresses table that has the email column as the primary key.
If I run the bottom half, I can find all the dups but cant seem to filter them when inserting them.

INSERT INTO cust_email.dbo.addresses (fname, lname, email)
SELECT p.fname, p.lname, p.email
FROM marketing.dbo.marketingmaster p
WHERE p.email !=''
AND p.email is not null
AND patindex('%@%',p.email) >0
AND patindex('%.%',p.email) >0
AND NOT EXISTS
(SELECT email, count(ID)as count FROM marketing..marketingmaster
WHERE email !=''
AND email is not null
AND patindex('%@%',email) >0
AND patindex('%.%',email) >0
GROUP by email
HAVING count(ID) > 1)

Thanks in advance for any help.
Jan 23 '08 #1
1 2347
mnymoen
3 New Member
I figured it out.
My exists syntax was incorrect.
Jan 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
57638
by: Don | last post by:
Hi, I am moving from Sybase to Oracle and I used to be able to do update statement like this in Sybase: UPDATE TABLE1 SET T1.field1 = T2.field2 FROM TABLE1 T1, TABLE2 T2 WHERE T1.field2...
3
37152
by: KathyB | last post by:
Hi, I have 2 tables: tblStations StationID Station tblStationUser RecordID UserName Station I'm trying to come up with a dataset that contains the
7
9176
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
1
1526
by: mlrehberg | last post by:
Hi, New to writing sql script I get this error in my sql script Server: Msg 512, Level 16, State 1, Line 1 Subquery returned more than 1 value. This is not permitted when the subquery...
2
1089
by: Tim | last post by:
I am trying to query my SQL 2000 SP3 database for some info but can't seem to figure out how to get what I want. I have a fairly simple situation.... the data I want is in two tables, one with a...
1
332
by: Tom Farmen | last post by:
Hi! I'm quite new to using SQL in Access and I therefore need some help wth the following problem: Lets say I have all my data in one table to simplify things and I want to create a SQL Query...
15
1891
by: MLH | last post by:
Mr Leigh Purvis gave me a very clever piece of SQL to accomplish what is probably an uncommon objective. In it, he uses the EXISTS operator. I can find no documentation on it in A97 HELP. I would...
11
1700
by: Sinan Osan | last post by:
Hello, I want to select the users from 'userTBL' which does not have any property in 'live_properties' table, Both table has a same column called 'username' I have 2 tables called...
1
4129
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.