I have two tables, the value of NDC_10 for table test is a 10 digit code while the value of PRODUCTNDC in table product is a 8 digit code. I am trying to select all of the rows in which the 8 digit code is inside the 10 digit code such as:
0123456789 = 10 digits
12345678 = 8 digits
I have come up with something like this logically, but I do not know how to nest the 2 wild characters inside the search of the other table
select NDC_10
FROM test, product
WHERE (NDC_10 LIKE '_product.PRODUCTNDC_')
See: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_locate
And: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html
And never ever use implicit join syntax, it is an antipattern.
The reason is that it’s too easy to do a cross join which in 99,99% of all cases is not what you want.