home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2736
Discussions: 186,607, Posts: 2,227,058, Members: 230,242
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old October 1st, 2008, 01:41 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
vbscript and SQL versus joins

I have a database - with two tables, one which contains different countries and one containing user names and their choices - they are connected (relational) via a field called country number.

Now i want to make a selection showing which contries a user has picked - meaning which contries from the "available" table, has a certain user NOT selected. - this is my code but it doesnt work.

'VB
sub main()
Dim Portal
Dim Query
Dim uRS
Dim uSQL

'Connect to DB
'*************
Set uConn = server.CreateObject("ADODB.Connection")
uConn.Open Application("countrystr")

uSQL = "SELECT DISTINCT CountryCode, Name, User, CountrySelected FROM Contries FULL OUTER JOIN Selected ON countries.CountryCode <> Selected.CountrySelected WHERE User = 'Tom' AND countries.CountryCode <> Selected.CountrySelected ORDER BY CountryCode"

Set uRS = uConn.Execute(uSQL)

Do While not uRS.EOF
Content.Add(uRS("CountryCode") & " - " & uRS("Name") & &"</a><BR />")
uRS.MoveNext
Loop
Set uRS = Nothing
uConn.Close
end sub

Ulrik48 is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Old October 1st, 2008, 02:09 PM     #2 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 20,457
I dont believe you can use a join with <>
Wouldn't make much sense
The FULL OUTER JOIN should fulfill that purpose

vass0922 is online now   Reply With Quote
Old October 1st, 2008, 03:04 PM     #3 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
So what you mean is

uSQL = "SELECT DISTINCT CountryCode, Name, User, CountrySelected FROM Contries FULL OUTER JOIN Selected ON countries.CountryCode = Selected.CountrySelected WHERE User = 'Tom' AND countries.CountryCode <> Selected.CountrySelected ORDER BY CountryCode"

Ulrik48 is offline   Reply With Quote
Old October 1st, 2008, 03:22 PM     #4 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
It doesn't work - it gives all contries that the user has selected, I want those from the first table, that the user did not select
Ulrik48 is offline   Reply With Quote
Old October 1st, 2008, 03:23 PM     #5 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
uSQL = "SELECT DISTINCT CountryCode, Name, User, CountrySelected FROM Contries FULL OUTER JOIN Selected ON countries.CountryCode <> Selected.CountrySelected WHERE User = 'Tom' ORDER BY CountryCode"

Doesn't work either - same result
Ulrik48 is offline   Reply With Quote
Old October 1st, 2008, 03:56 PM     #6 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 20,457
OH then you need a left or right outer join, not full

try LEFT, see if you get the correct results.. if that doesn't work try RIGHT
vass0922 is online now   Reply With Quote
Old October 1st, 2008, 04:18 PM     #7 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
I did try both, both either works
Ulrik48 is offline   Reply With Quote
Old October 1st, 2008, 11:42 PM     #8 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 20,457
tell me this thing is a typo?
Code:
uSQL = "SELECT DISTINCT CountryCode, Name, User, CountrySelected FROM Contries FULL OUTER JOIN Selected ON countries.CountryCode <> Selected.CountrySelected WHERE User = 'Tom' AND countries.CountryCode <> Selected.CountrySelected ORDER BY CountryCode"
you're linking contries instead of countries
vass0922 is online now   Reply With Quote
Old October 2nd, 2008, 03:37 AM     #9 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
its a typo - Im actually getting output - either all records from Selected or all records in Selected where User = "ULS" or nothing.
I Want it to show all records from Countries, that ULS did not select
Ulrik48 is offline   Reply With Quote
Old October 2nd, 2008, 04:09 AM     #10 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 8
I have solved it - yes yes
Ulrik48 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
China joins Jerry Falwell... Theophylact IMO Community 14 February 24th, 2006 02:51 PM
Intel dual-core versus dual Opteron versus single core P4 ArcticFox Processors, Memory, and Overclocking 16 July 10th, 2005 09:01 PM
VBScript SQL Limitations? jkrohn Webmastering and Programming 7 October 7th, 2004 04:11 PM
MS Access: Inner Joins vs. Outer Joins NoLimit Webmastering and Programming 5 November 10th, 2003 01:25 AM

Most Active Discussions
Is It Just Me? (531)
Misery Loves Company... (1849)
Why Does the MOON Grow Bigger as It.. (18)
heatsink issue (10)
New Mobo (18)
UPGRADING C/D DRIVE TO 250GB & .. (14)
1 internet. 1 house. 3 computer. ho.. (13)
SSD's, RAID, and External Backup (7)
Is This A Compatible Gaming PC? (18)
Recent Discussions
32 or 64 bit vista (4)
Big problem with my PC (2)
system restore 'next' button wo.. (2)
Building my first PC and need s.. (1)
firewall (1)
C++ compiler suggestions (4)
Official World of Warcraft Thre.. (4529)
Programming question (2)
UPGRADING C/D DRIVE TO 250GB &a.. (14)
FS: Dell 6000 laptop, modded 36.. (2)
Apple iPod touch 16 GB $200 (4)
Six 28-Disc Cross Design Black .. (4)


All times are GMT -4. The time now is 12:22 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28