Reputation: 109
I have two table as table1 and table2 given below:
I want to have the value of only those table_name from table1 which has there id in print_table column in table 2.
I have implemented the following query but it returns only one value:
SELECT * FROM print_tabel_permission_admin WHERE id IN (select print_table from secondary)
Upvotes: 0
Views: 34
Reputation: 521674
Use FIND_IN_SET
:
SELECT DISTINCT
t1.table_name
FROM table1 t1
INNER JOIN table2 t2
ON FIND_IN_SET(t1.id, t2.print_table) > 0;
You should probably move away from storing CSV data in your tables like this. Instead, break out the IDs in table2
onto separate rows. This will make your life easier.
Upvotes: 1