Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Quick Help on a SQL Script Addition 1

Status
Not open for further replies.

grippy

Programmer
Dec 2, 2004
161
US
I have shorten the code to make it easier to read on the forums. Basically what it is doing now is finding all of my products and putting them into another table which I export. However if the price is NULL then it is just putting a default price of 0.00. Some advertiser's disreguard all $0 items however my new one does not and they are listing all my non completed items. What needs to be added to this code for it to exclude all NULL items in the tblProduct.salePrice so that my tblFeed does not show them? Thanks for the help guys.

Code:
DELETE  tblFeed INSERT INTO tblFeed (Category, Mfr, Title, Price)
SELECT  tblProduct.FeedCategory AS Category,
	tblCompany.name AS Mfr, 
        tblCompany.name + ' ' + tblProduct.productName AS Title, 
	ISNULL(tblProduct.salePrice, '0.00') AS Price
                                                        
FROM          tblProduct INNER JOIN
              tblCompany ON tblProduct.company = tblCompany.ID INNER JOIN
 
Add this...
Code:
Where tblProduct.SalePrice Is not NULL


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Code:
SELECT tblProduct.FeedCategory AS Category,
       tblCompany.name AS Mfr,
       tblCompany.name + ' ' + tblProduct.productName AS Title,
       ISNULL(tblProduct.salePrice, '0.00') AS Price
FROM   tblProduct
INNER JOIN tblCompany ON tblProduct.company = tblCompany.ID
WHERE tblProduct.salePrice IS NOT NULL

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
who im a little slow today I should have known that. Thank you now I can stop wasting money in advertising!
 
DELETE tblFeed INSERT INTO tblFeed (Category, Mfr, Title, Price)
SELECT tblProduct.FeedCategory AS Category,
tblCompany.name AS Mfr,
tblCompany.name + ' ' + tblProduct.productName AS Title,
tblProduct.salePrice AS Price

FROM tblProduct INNER JOIN
tblCompany ON tblProduct.company = tblCompany.ID INNER JOIN
....
where tblProduct.salePrice IS NOT NULL

-----------

Am I missing something?
 
ok I have one more question. The field isnt shown in the example above but i have a field called tblProduct.productCode, since I sell car parts 1 product code may work on multiple vehicles. Everytime i have repeated product codes it only uses one and removes the others automatically from the advertising company. Any advice on how to make it so that if product "21-400" is in the DB 5 times then it will put them into tblFeed.code as:

21-400
21-400-1
21-400-2
21-400-3
21-400-4

This will be extremely helpful. I only want to do this with duplicate product codes though I dont want any of the other ones changed. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top