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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql statement error

Author  Topic 

sqlnewbie82
Starting Member

11 Posts

Posted - 2007-10-22 : 04:40:25
HI

i am getting a error with my sql statement. i am trying to join to two tables together. this is the error it is giving.

Syntax error (missing operator) in query expression '12Package_Listing.Package_id LIKE 11Package.Package_id'.

my sql statement is
string strSQL1 = "select * from 12Package_Listing INNER JOIN 11Package ON 12Package_Listing.Package_id LIKE 11Package.Package_id";

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-22 : 04:51:17

select * from [12Package_Listing] INNER JOIN [11Package] ON [12Package_Listing].Package_id LIKE [11Package].Package_id



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 06:32:31
Also like Without % doesnt make any sense

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlnewbie82
Starting Member

11 Posts

Posted - 2007-10-22 : 07:04:15
hi thanks for the input. that sql statement seems to work, but i have problem. i am trying to display package name which is stored in the 11Package table. but i am getting an error. i can only display the package ids

help
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 08:14:49
quote:
Originally posted by sqlnewbie82

hi thanks for the input. that sql statement seems to work, but i have problem. i am trying to display package name which is stored in the 11Package table. but i am getting an error. i can only display the package ids

help


What is the error?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlnewbie82
Starting Member

11 Posts

Posted - 2007-10-22 : 08:39:22
i am getting this error
Syntax error. in query expression '(select Package_name from 11Package where 11Package.Package_id = 12Package_Listing.Package_id)'

this is my sql query
select * , (select Package_name from 11Package where 11Package.Package_id = 12Package_Listing.Package_id) as Package_name from 12Package_Listing

regards
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 08:45:35
You need to use braces around table names as Tan suggested

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-22 : 09:27:37
Duplicate post too
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=91386



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -