Groups | Blog | Home
all groups > sql server (microsoft) > april 2007 >

sql server (microsoft) : String function LEFT in where clause possible?


mail-rk NO[at]SPAM gmx.de
4/25/2007 6:21:37 AM
Hi, I am brand new to MS SQL and an have to create a select statement
for two tables. In each table I have a Field 'pc-name'. In table1 'pc-
name' is 'PC001XP1' or 'PC20009'. In table2 the SAME machine is called
'PC001XP1_ROOM12' or 'PC20009_ROOM144'. I have to match these tables.
I tried a select statement like this one:
'select * from table1 where table1.pcname = LEFT(table1.pcname,
(charindex('_', table2.pcname)-1))'

The query has a empty result set. Where am I wrong. How can I solve
this problem?

Regards
Richard
Ed Murphy
4/25/2007 9:24:28 AM
[quoted text, click to view]

That SELECT statement contains a couple of basic errors. Start
with this:

SELECT *
FROM TABLE1, TABLE2
WHERE TABLE1.PCNAME = LEFT(TABLE2.PCNAME,
AddThis Social Bookmark Button