Need help pls
I have table 1, with column A, B ,C.
Table 2, with G, H, I, I need your help in writing an query that would search value of G in column C and display if it matches. Value of G would be part of short string data type of C.Table 1 and 2 are related with column A and I.
Issues is that since value of G is not exactly same as that of C, we need to search the match string og G in C.
Your help is highly appreciated.
- Changed type Tom PhillipsModerator Monday, July 15, 2013 3:58 PM
Just guessingCREATE TABLE w
INSERT INTO W VALUES ('URIDIMANT')
INSERT INTO W VALUES ('DIMANT')
INSERT INTO W VALUES ('URIRON')
INSERT INTO W VALUES ('RR')
CREATE TABLE w1
INSERT INTO W1 VALUES ('URIDIMANT')
INSERT INTO W1 VALUES ('DIMANTRON')
INSERT INTO W1 VALUES ('URI')
INSERT INTO W1 VALUES ('URIRON')
SELECT W.COL1,W1.COL1 FROM W JOIN W1
ON W.col1 LIKE '%' + W1.col1 + '%'
DROP TABLE W
DROP TABLE W1
Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Blog: Large scale of database and data cleansing
Remote DBA Services: Improves MS SQL Database Performance
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. Why should we answer you? How should we treat people that this rude? Want to try again and treat us so badly?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL