How to write a SQL like query with table column ?
I have two tables table1 and table2.
Table1 has Notes
Table2 has billid
select * from table1
where Notes like select billid from table2
You are wanting a
If the exact
BillID is found in
select table1.* from table1 INNER JOIN table2 ON table1.column1=table2.billid
You could also do this using
IN in the WHERE clause if you truly don't need any records from your
table2 in the result set:
select * from table1 where column1 in (SELECT billid FROM table2);
Which is pretty close to what you were aiming for in your attempted query.
Lastly, if you actually mean
LIKE which is more of a wildcard match in SQL terms where the
column1 merely has to contain a
billid then back to the join:
select table1.* from table1 INNER JOIN table2 ON table1.column1 LIKE '%' + table2.billid + '%'