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 |
|
sqlnewbie82
Starting Member
11 Posts |
Posted - 2007-10-22 : 08:44:19
|
| i have a problem with joining two tables. i am comparing to see if the package id exists in the other table and then it prints out the package name in the other tablebut i am getting this error, is there anything wrong with my sql statementi am getting this errorSyntax error. in query expression '(select Package_name from 11Package where 11Package.Package_id = 12Package_Listing.Package_id)'this is my sql queryselect * , (select Package_name from 11Package where 11Package.Package_id = 12Package_Listing.Package_id) as Package_name from 12Package_Listingregards |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-10-22 : 08:51:55
|
| [code]Select t1.* , t2.Package_name from 12Package_Listing t1 JOIN 11Package t2on t2.Package_id = t1.Package_id[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-22 : 08:59:40
|
| As I told you in the other thread you need to use [] around the table names if they dont start with alphabetMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-22 : 09:23:17
|
And to wrap things upSELECT t12.*, t11.Package_NameFROM [12Package_Listing] AS t12LEFT JOIN [11Package] AS t11 ON t11.Package_ID = t12.Package_ID E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sqlnewbie82
Starting Member
11 Posts |
Posted - 2007-10-22 : 09:30:14
|
| thanks alot i managed to do it :) |
 |
|
|
|
|
|