Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Like Syntax error.

Status
Not open for further replies.

nmmure

Programmer
Jun 8, 2006
200
US
Hi,

I am using SQL Server 2000. Below I am coping my SQl Query it is working fine.

Select A.account, C.customerName from account A
Join customerName c on C.customerno = a.customerno
where A.account = '10001147' and C.customerName '%A'

The above query is working fine. Customer names are availabe on another table Emp column name customerName.

Here I am trying pass CustomerName instead of A.
It is not showing any values. Pls correct my below SQl

Select A.account, C.customerName from account A
Join customerName c on C.customerno = a.customerno
Join Emp E on E.customername = c.customerName
where A.account = '10001147' and C.customerName like %' + @ E.customername + '

Pls help me.

Thanks
Mure



 
It would be helpful if you showed some sample data and desired output.
 
Code:
Select A.account,
       C.customerName
from account A
Join customerName c on C.customerno = a.customerno
Join Emp E  on E.customername = c.customerName
where A.account = '10001147' and
      C.customerName like '%' + @E.customername

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
W/o @ in front of E.CusttomerName:
Code:
Select A.account,
       C.customerName
from account A
Join customerName c on C.customerno = a.customerno
Join Emp E  on E.customername = c.customerName
where A.account = '10001147' and
      C.customerName like '%' + E.customername

Also what types are both field:
customerName.customerName
and
Emp.customerName


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Hi,
My First Query will display following Records

10001147 Antony
10001147 Anand

Using Like %A it is showing above records.

same account 10001147 will have some Names starting other Alfabytes. I need to pull the names, those names are available in Emp table, I trying to pass E.customername instead of A.

Pls correct me my SQl statement.

Expected output was. these name are available on Emp table

10001147 Antony
10001147 Anand
10001147 Elegen
10001147 Flan
10001147 John
10001147 Jack
10001147 Piper
10001147 Susanti

Thanks
Mure

 
I am appreciating your help. Thanks bborissov.

My Query is working fine.

Thanks
Mure
 
Mure,
I am totally confused here. Can you provide some simple data and desired result?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
You don't need the where C.customerName like '%' + E.customername if you are already joining on those columns
 
Good catch, jbenson001
I even didn't saw this :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top