I am new to SQL and have been trying for sometime now to get this query to work (provided to me by another member as noted). I'm trying to select data from two table containing promotional data and inserting unique account rows selected into a third table:
BUYER:
AccountNumber
SaleNumber
Price
... other Buyer related data
CountryCode
State
ZipPostCode
City
SELLER:
AccountNumber
SaleNumber
Price
... other Seller related data
CountryCode
State
ZipPostCode
City
SELECTIONS:
CampaignID
AccountNumber
CountryCode
State
ZipPostCode
City
**********************************************************
Here's the query by Terry L. Broadbent - DBA (TLBROADBENT)
INSERT Selections
(AccountNumber, CountryCode,
State, ZipPostCode, City)
SELECT
AccountNumber, CountryCode,
State, ZipPostCode, City
(SELECT
AccountNumber, CountryCode,
State, ZipPostCode, City
FROM Buyer
WHERE (SaleNumber = 'nyc00001')
AND (Price > 1000)
UNION
SELECT
AccountNumber, CountryCode,
State, ZipPostCode, City
FROM Seller
WHERE (SaleNumber = 'nyc00001')
AND (Price > 1000)) As Qry
***********************************************************
The first problem I had with this query was a syntax problem, I added "INTO", reran the query and got a "unsupported" error message.
***********************************************************
Thanks,
Rick
BUYER:
AccountNumber
SaleNumber
Price
... other Buyer related data
CountryCode
State
ZipPostCode
City
SELLER:
AccountNumber
SaleNumber
Price
... other Seller related data
CountryCode
State
ZipPostCode
City
SELECTIONS:
CampaignID
AccountNumber
CountryCode
State
ZipPostCode
City
**********************************************************
Here's the query by Terry L. Broadbent - DBA (TLBROADBENT)
INSERT Selections
(AccountNumber, CountryCode,
State, ZipPostCode, City)
SELECT
AccountNumber, CountryCode,
State, ZipPostCode, City
(SELECT
AccountNumber, CountryCode,
State, ZipPostCode, City
FROM Buyer
WHERE (SaleNumber = 'nyc00001')
AND (Price > 1000)
UNION
SELECT
AccountNumber, CountryCode,
State, ZipPostCode, City
FROM Seller
WHERE (SaleNumber = 'nyc00001')
AND (Price > 1000)) As Qry
***********************************************************
The first problem I had with this query was a syntax problem, I added "INTO", reran the query and got a "unsupported" error message.
***********************************************************
Thanks,
Rick