Riyaz
Riyaz

Reputation: 1

SQL string pair matching

I need help with writing a SQL query.

I have column A, which can carry values like "A-01" , "B-01", B-02" and so on...

I have column B, which can carry values like "A01", "B01", B02" and so on....

I want to write a query where data in column A is A-01 and column B is A01 and

data in column A is B-01 and column B is B01 and

data in column A is C-02 and column B is C02 and so on.

I am basically looking for data rows, which forms this kind of pair, out of all possible combinations.

I am looking for some kind of variable string matching here. But I don't know if it is possible.

Any help/suggestion is appreciated. Thanks, -Riyaz

Upvotes: 0

Views: 244

Answers (1)

silly
silly

Reputation: 7887

i hope this helps:

SELECT * FROM your_table
WHERE REPLACE(field_a, '-', '') = field_b

Upvotes: 3

Related Questions