Sorry, the temp tables were for me only, I don't have the originals see :O)
Get rid of the hashs and change the names to your table names Justin and it should work. Ade -----Original Message----- From: Robertson-Ravo, Neil (RX) [mailto:[EMAIL PROTECTED] Sent: 05 January 2004 15:50 To: '[EMAIL PROTECTED]' Subject: RE: [ cf-dev ] stupid sql question I havent had a chance to look at it, and this will work, but you shouldn't need to use a temporary table for this......will have a look post-work and see what I can come up with.! -----Original Message----- From: Adrian Lynch [mailto:[EMAIL PROTECTED] Sent: 05 January 2004 15:55 To: '[EMAIL PROTECTED]' Subject: RE: [ cf-dev ] stupid sql question This seems to work on SQL Server.... CREATE TABLE #product ( pk int, product varchar(50) ) CREATE TABLE #shop ( pk int, shop varchar(50) ) CREATE TABLE #shopProduct ( fkProduct int, fkShop int ) INSERT INTO #product ( pk, product ) VALUES ( 1, 'pro_1' ) INSERT INTO #product ( pk, product ) VALUES ( 2, 'pro_2' ) INSERT INTO #product ( pk, product ) VALUES ( 3, 'pro_3' ) INSERT INTO #product ( pk, product ) VALUES ( 4, 'pro_4' ) INSERT INTO #shop ( pk, shop ) VALUES ( 1, 'shop_1' ) INSERT INTO #shop ( pk, shop ) VALUES ( 2, 'shop_2' ) INSERT INTO #shop ( pk, shop ) VALUES ( 3, 'shop_3' ) INSERT INTO #shopProduct ( fkProduct, fkShop ) VALUES ( 1, 1 ) INSERT INTO #shopProduct ( fkProduct, fkShop ) VALUES ( 1, 2 ) INSERT INTO #shopProduct ( fkProduct, fkShop ) VALUES ( 2, 1 ) INSERT INTO #shopProduct ( fkProduct, fkShop ) VALUES ( 3, 2 ) SELECT Shop, Product, CASE WHEN sp.fkProduct IS NULL THEN 'no' ELSE 'yes' END AS 'Available' FROM #shop, #product LEFT OUTER JOIN #shopProduct AS sp ON ( #product.pk = sp.fkProduct ) ORDER BY Shop It looks right to me, but you'll know for sure if it's doing what you need. Ade -----Original Message----- From: Justin [mailto:[EMAIL PROTECTED] Sent: 05 January 2004 15:16 To: [EMAIL PROTECTED] Subject: RE: [ cf-dev ] stupid sql question yes... if there is a entry for that product in that shop... feeling humiliated.... :-) Justin -----Original Message----- From: Robertson-Ravo, Neil (RX) [mailto:[EMAIL PROTECTED] Sent: 05 January 2004 14:52 To: '[EMAIL PROTECTED]' Subject: RE: [ cf-dev ] stupid sql question Where is the availability flag? Is it simply if it exists in a shop? -----Original Message----- From: Justin [mailto:[EMAIL PROTECTED] Sent: 05 January 2004 14:54 To: Cfuk Subject: [ cf-dev ] stupid sql question My brain is still in xmas mode, and what should be simple sql is a challange! I want to do a query, that lists all the products , with a column with a yes/no (boolean/bit) column to say if the product is available in that shop or not so with [Product] pk product ------------------ 1 product1 2 product2 3 product3 [Shop] pk shop -------------- 1 shop_1 2 shop_2 [ShopProduct] FKProduct FKShop ------------------- 1 1 1 2 2 1 3 2 I should have Shop product available ------------------------------ shop_1 product1 yes shop_1 product2 yes shop_1 product3 no shop_2 product1 yes shop_2 product2 no shop_2 product3 yes I know its a CROSS JOIN between shop and product with a outer? join on the ShopProduct table but just can't get it together... Thanks Justin -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant, Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business, Registered in England, Number 678540. It contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender or call our switchboard on +44 (0) 20 89107910. The opinions expressed within this communication are not necessarily those expressed by Reed Exhibitions. Visit our website at http://www.reedexpo.com -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant, Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business, Registered in England, Number 678540. It contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender or call our switchboard on +44 (0) 20 89107910. The opinions expressed within this communication are not necessarily those expressed by Reed Exhibitions. Visit our website at http://www.reedexpo.com -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
