Is it possible to have an “IN” statement within a left join clause?
I have two tables with two columns:
Table 1: Table 2:
Column1: Column2:
192192, 192192
119202 119202
810395 810395
975643, 975643
908574,, 908574
As you can see, tbl1.col1 has entries can have entries with commas trailing or have none at all. I need to join the two tables where column 1 contains column 2 or where they are equal. It made sense to be to join where column1 includes column 2. Maybe there’s a better way to accomplish the join?
I need to join the two to access data in table 2. So the columns just need to align while allowing for a potential comma or two in column 1. Any suggestions?
If this is just some sort of one-time deal or a staging table and not your real prod table:
(this one works no matter where inteh number the commas are)
or
(you may or may not need the cast depending onthe data types of the tow columns, I was assuming one was varchar and the other was integer)
or
(this only works if the value will always be the same length
If this is a real prod table, then you could have performance issues joining on a function, so fix the data instead.