Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mlawton40
Starting Member
15 Posts |
Posted - 2008-02-19 : 06:02:39
|
| Hey,I have the following 2 tables with the following fields:PostcodePostcodeTownCoursesTownI have a textbox which accepts a Postcode and then a submit button. When the submit button is clicked I want to:SELECT * from Courses WHERE the postcode entered matches postcode from the table Postcode and therefor selects the town from postcode to be able to select the results from Courses.Hope this makes sense, if not then let me know, i can probably word it better. I'll keep trying, any help would be great!Cheers, Mark |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-19 : 06:07:03
|
| [code]Select * from courses c join PostCode pcon c.town = pc.townwhere <some-condition>[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-02-19 : 06:12:22
|
| I think this is what you're looking for . Where are the results held?CREATE TABLE #postcode(postcode VARCHAR (20),town VARCHAR(20))CREATE TABLE #courses(town VARCHAR (20),course VARCHAR(20))INSERT INTO #postcode SELECT 'BN1','London'UNIONSELECT 'BN2','Brighton'INSERT INTO #courses SELECT 'London','SQL'UNIONSELECT 'Brighton','DTS'SELECT c.course,c.town FROM #courses as cINNER JOIN #postcode as p ON c.town = p.townWHERE p.postcode = 'BN1'DROP TABLE #postcodeDROP TABLE #coursesJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
|
|
|