I have two relational tables, t1
has the column call_number
and t2
has phone_number
.
Example tables:
+----+-------------+
| id | call_number |
+----+-------------+
| 1 | 36202665476 |
+----+-------------+
+----+-----------------+
| id | phone_number |
+----+-----------------+
| 1 | +36 20 266-5476 |
+----+-----------------+
I have to write a query which give back these two "matching" rows, using regexp, without any modification on the database.
SELECT t1.*,t2.*
FROM t1,t2
WHERE
t1.call_number REGEXP concat( t2.phone_number, '[^0-9]')
So in the query I have to remove unnecessary characters (from t2.phone_number
) THEN compare that "trimmed" column with t1.call_number
to find a match.
Any advice comes in handy.
Thanks